如何将列表添加到另一个列表,例如:
List<string> list = new List<string>();
我想将此列表添加到另一个列表中,例如:
List<List> list2 = new List<List>()
答案 0 :(得分:4)
var list1 = new List<string>();
var list2 = new List<string>();
var parentList = new List<List<string>> {list1, list2};
答案 1 :(得分:1)
创建嵌套类,并在每个类中创建一个List类型的属性(Of xxSubClassxx)
vb的例子是:
class list1
property list as new List(of xfirstlist)
class xfirstlist
property list2 as new list(of xSecondList)
class xSecondList
end class
end class
end class