c# - 将 List<int> 转换为 List<List<int>>

标签 c# .net list collections

我可以转换List<int>吗?至 List<List<int>>在 C# 中? 当我使用这样的构造时

List<int>element=new List<int>();
List<List<int>>superElement= new List<List<int>>(element);

我出错了,但我可以用其他方式做到这一点吗?

最佳答案

你可以这样做:

List<List<int>> superElement = new List<List<int>>();
superElement.Add(element);

关于c# - 将 List<int> 转换为 List<List<int>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15921404/

相关文章:

c# - Mono 上的 System.Threading.Thread.Sleep 和 Timeout.Infinite

c# - LINQ:将 SQL WITH 子句转换为 LINQ 和 Entity Framework

c# - ManualResetEvent WaitOne(timeout) 提前返回。任何想法为什么?

list - Groovy 压缩列表或按级别展平

javascript - 在有序/无序列表上按回车键在每个 <li> 元素后添加 <br>

c# - MSMQ为什么不发送空格字符?

c# - 每个应用程序 session 的 Nlog 固定文件名

c# - 将原始数据加载到位图中 - 我做错了什么?

.net - Mudblazor - 如何在 MudTable 上使用 InputFile?

r - 如何将dplyr过滤器应用于数据帧列表?