Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法从其他类分配返回值_C#_List_Inheritance - Fatal编程技术网

C# 无法从其他类分配返回值

C# 无法从其他类分配返回值,c#,list,inheritance,C#,List,Inheritance,我对C#有点陌生,似乎我在给我在控制器中创建的列表赋值时遇到了问题。我试图从返回列表值的repo类中分配一个值 我得到的信息是 未给出与“Repo.SearchClient(ClientInfo)”的必需形式参数“client”对应的参数 我的控制器: public ActionResult SearchResult() { Repo repo = new Repo(); List<ClientInfo> searchResult =

我对C#有点陌生,似乎我在给我在控制器中创建的列表赋值时遇到了问题。我试图从返回列表值的repo类中分配一个值

我得到的信息是

未给出与“Repo.SearchClient(ClientInfo)”的必需形式参数“client”对应的参数

我的控制器:

    public ActionResult SearchResult()
    {
        Repo repo = new Repo();
        List<ClientInfo> searchResult = new List<ClientInfo>();
        searchResult = repo.SearchClient(); // error here 
        JsonResult result = new JsonResult();
        result.Data = searchResult;
        result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
        return result;
    }

搜索客户端方法需要ClientInfo作为参数

public List<ClientInfo> SearchClient(ClientInfo client) // required parameter

搜索客户端方法需要ClientInfo作为参数

public List<ClientInfo> SearchClient(ClientInfo client) // required parameter

您的Repo方法需要参数“ClientInfo client”,但您没有提供该参数。您的Repo方法需要参数“ClientInfo client”,但您没有提供该参数。
public List<ClientInfo> SearchClient(ClientInfo client) // required parameter
List<ClientInfo> searchResult = new List<ClientInfo>();
    searchResult = repo.SearchClient(); // no parameter
var clientInfo = new ClientInfo()
    {
        ClientName = "test client"
    }; // create a new ClientInfo object

var clientList = SearchClient(clientInfo); // call the search method and assign the results to a list