我可以在c#中将List<int>转换为List<List<int>>吗?当我使用这样的结构时
List<int>element=new List<int>();
List<List<int>>superElement= new List<List<int>>(element);我有一个错误,但我可以用另一种方式来做这件事吗?
发布于 2013-04-10 17:02:55
你可以这样做:
List<List<int>> superElement = new List<List<int>>();
superElement.Add(element);发布于 2013-04-10 17:02:32
List<int>element=new List<int>();
List<List<int>>superElement= new List<List<int>> { element };这样就行了。你不能在构造函数中传递列表。
发布于 2013-04-10 17:02:32
试试这个:
var element = new List<int>();
var superElement = new List< List<int> >(){ element };https://stackoverflow.com/questions/15921404
复制相似问题