[英]EPiServer: populate selectionfactory drop down list with content from array?
[英]Populate list from array
如果我有一個數組。 我可以從該數組中填充一個通用列表:
Foo[] fooList . . . (assume populated array)
// This doesn't seem to work
List<Foo> newList = new List<Foo>(fooList);
您可以將數組轉換為列表:
string[] strings = { "hello", "world" };
IList<string> stringList = strings.ToList();
您正在尋找List(t).AddRange方法
正如@korki 所說, AddRange 可以工作,但是您發布的代碼應該可以正常工作。 例如,這編譯:
var i = new int[10];
var list = new List<int>(i);
你能告訴我們更多你的代碼嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.