c# - 如何在 C# 中创建一个 List<int> 数组?

标签 c# .net arrays list

我有一个问题,我需要一个 arrayList 数组。

例如,如果我们采用一个由 int 类型的 ArrayList 构成的数组,它将是这样的:

int[]<List> myData = new int[2]<List>;

myData[0] = new List<int>();
myData[0].Add(1);
myData[0].Add(2);
myData[0].Add(3);


myData[1] = new List<int>();
myData[1].Add(4);
myData[1].Add(5);
myData[1].Add(6);

myData[0].Add(7);

我们如何在 C# 中实现上述数据结构?

在 C 中,它就像一个 LinkedList 的数组。我如何在 C# 中执行相同的操作?

最佳答案

var myData = new List<int>[]
{
    new List<int> { 1, 2, 3 },
    new List<int> { 4, 5, 6 }
};

关于c# - 如何在 C# 中创建一个 List<int> 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4864557/

相关文章:

java - 排列数组元素正负零

c# - 检查 XML 节点是否具有 Linq C# 的属性?

C# AWS SQS Client 由于其保护级别而无法访问

c# - EF Core 5.0 中的多对多关系是否可以配置为仅保留一个导航属性(在一侧)?

.net - 您可以在 OpenRasta 中同时发布文件和资源吗?

C程序: Breaking an int into an int array[]

c# - 如何实现一个事件类

c# - 在 C# 中创建正弦波或方波

C# 等效于 "My.Computer.Network.Ping"

c++ - 如何在不分配更多存储空间的情况下从数组初始化 vector ?