请提供C#.net中嵌套列表的示例

本文关键字:列表 嵌套 net | 更新日期: 2023-09-27 18:24:28

如何将列表添加到另一个列表,例如:

List<string> list = new List<string>();

我想把这个列表添加到另一个列表中,类似于:

List<List> list2 = new List<List>()

请提供C#.net中嵌套列表的示例

var list1 = new List<string>();
var list2 = new List<string>();
var parentList = new List<List<string>> {list1, list2};

创建嵌套类,并在每个类中创建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