Ich habe dieses Modell in C#:Wie kann ich lösen Kann Typ System.Collections.Generic.List nicht implizit konvertieren?
public class interfaceModel
{
public string interfacename { get; set; }
public long id { get; set; }
}
und diesen Code schreiben:
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; }
}
Jetzt schreibe ich Code, der Methode aufzurufen:
public static List<interfaceModel> interfacefetch()
{
return Database.CompanyInterfaceFetch();
}
aber auf dieser Linie:
return Database.CompanyInterfaceFetch();
Ich erhalte diesen Fehler:
Error CS0029: Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.List
Wie kann ich dieses Problem lösen? Vielen Dank.
hast du zwei 'interfaceModel'? –
@ DanielA.White nein habe nur eine SchnittstelleModell –
der Compiler sagt, Sie haben 2 –