我有这个模型在C#:我如何解决不能隐式转换类型System.Collections.Generic.List?
public class interfaceModel
{
public string interfacename { get; set; }
public long id { get; set; }
}
和编写代码:
public static List<interfaceModel> CompanyInterfaceFetch()
{
var database = new DataBaseDataContext();
var companyinterface = new CompanyInterface();
var interfacelist =
database.CompanyInterfaces.Select(x => new interfaceModel { interfacename = x.InterfaceName, id=x.id});
return interfacelist.ToList();
}
// database model
public class interfaceModel
{
public string interfacename { get; set; }
public long id { get; set; }
}
现在我写的代码调用该方法:
public static List<interfaceModel> interfacefetch()
{
return Database.CompanyInterfaceFetch();
}
,但在这条线:
return Database.CompanyInterfaceFetch();
我得到这个错误:
Error CS0029: Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.List
我该如何解决这个问题?谢谢。
你有两个'interfaceModel'吗? –
@ DanielA.White没有只有一个interfaceModel –
编译器说你有2 –