c#错误无法将collection.generic.list转换为类

c#错误无法将collection.generic.list转换为类,c#,C#,我想将某个方法的结果添加到列表中,但显示: Cannot implicitly convert type 'System.Collections.Generic.List<FontysFood.Classes.VoedingswaardenList>' to 'FontysFood.Classes.VoedingswaardenList' 有人知道如何修复此错误吗?假设我读对了,您尝试添加一个集合,但只能使用添加单个项目,而不能添加整个集合。尝试设置项属性(如果存在) Ma

我想将某个方法的结果添加到列表中,但显示:

Cannot implicitly convert type 'System.Collections.Generic.List<FontysFood.Classes.VoedingswaardenList>' to 'FontysFood.Classes.VoedingswaardenList'    

有人知道如何修复此错误吗?

假设我读对了,您尝试添加一个集合,但只能使用添加单个项目,而不能添加整个集合。尝试设置
属性(如果存在)

MainWindow.AlleVoed.Items = OproepProductList

或许

MainWindow.AlleVoed.AddRange(OproepProductList);

取决于Allevoid的实际情况。关键是您需要使用一个接受对象集合的方法,或者您可以编写一个循环来逐个添加它们。

据我所知,代码和错误消息是,
Oproep.GetWinkelmandjeInfo()
返回
VoedingswaardenList
的列表,但您尝试将其分配给非列表类型的变量。我假设您需要将
OproApproductList
的类型更改为
List
,如下所示:

List<VoedingswaardenList> OproepProductList = Oproep.GetWinkelmandjeInfo();
List-oproapproductlist=Oproep.GetWinkelmandjeInfo();
之后,JSteward的建议可能适用


或者,更改
GetWinkelmandjeInfo
方法,只返回一个
VoedingswaardenList
,而不是这些列表。这实际上取决于程序的语义,用外语很难理解。

我们需要看到更多的代码,尤其是因为它是用外语编写的。我添加了更多的代码!代码似乎仍然缺少对引发错误的列表对象的任何引用。
MainWindow.AlleVoed.AddRange(OproepProductList);
List<VoedingswaardenList> OproepProductList = Oproep.GetWinkelmandjeInfo();