如何在C#中将返回项转换为数组中的列表

时间:2017-09-25 06:50:50

标签: c# list arraylist

我希望将列表中的输出转换为列表中webservice返回项中的方法调用,并在此处返回数组。

catalogueItems = dataService.GetCatalogItemsFromFile(fileFullPath);

我需要将此dataService.GetCatalogItemsFromFile(fileFullPath)转换为列表。我该怎么做?

1 个答案:

答案 0 :(得分:1)

有很多方法,这个方法是而不知道类型

var list = new[] { dataService.GetCatalogItemsFromFile(fileFullPath) }.ToList()

如果你知道这种类型更好:

var list = new List<YourType>{ dataService.GetCatalogItemsFromFile(fileFullPath) };