創建它們的參數列表構建的對象列表我要完成這個樣子的(而不是在LINQ)從使用LINQ
List<FileInfo> InfoList: ... //Already populated.
List<string> fileNames = new List<string>(InfoList.Count);
InfoList.ForEach(s => filesNames.Add(s.Name.ToString()));
我已經寫上面的代碼。我想把這個下一部分轉換成linq。
List<ZipArchiveEntry> ZipList = new List<ZipArchiveEntry>(InfoList.Count);
for(int i = 0; i < InfoList.Count; i++)
{
ZipArchiveEntry = archive.CreateEntry(fileNames[i]);
ZipList.Add(ZipArchiveEntry);
}
所以基本上,我想知道你是否可以使用列表元素作爲函數的參數來構建對象列表。
要創建一個zip存檔條目,我需要調用方法archive.CreateEntry(filename),並且文件名是我已經構建的列表的元素。