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