我正在向 RootElement 的一部分添加某些值,如下所示:-
NavigationRoot = new RootElement("Menu"){ //Here we create the root of the elements
new Section("Pages"){
new StringElement ("Feed"),
new StringElement ("Messages"),
new StringElement ("Nearby"),
new StringElement ("Events"),
new StringElement ("Friends"),
},
现在,StringElements 是硬编码的。我想将我从 API 调用中获取的字符串列表传递给该部分。该列表将是动态的。如何传递此列表来创建具有列表中字符串值的项目部分?
感谢任何帮助。
最佳答案
如果你有一个字符串数组,你可以使用 Linq 试试这个:-
from page in myStringArray select new StringElement (page) as Element;
关于c# - 将列表传递给 RootElement c# 中的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34651991/