C# 区别于;列表<;int>;[,];及;列表<;列表<;int>&燃气轮机&引用;

C# 区别于;列表<;int>;[,];及;列表<;列表<;int>&燃气轮机&引用;,c#,C#,C#中的List[,]和List”有什么区别 我知道打电话是不同的,也是为了获得职位,但目的是一样的吗 我见过两次实现具有相同的结果,并且实现了这两种形式。List[,]是列表的二维数组。您应该定义不能更改的“矩阵”大小。创建后,您可以在单元格中添加列表: List<int>[,] matrix = new List<int>[2, 3]; // size is fixed matrix[0, 1] = new List<int>(); // assign l

C#中的
List[,]
List”
有什么区别

我知道打电话是不同的,也是为了获得职位,但目的是一样的吗

我见过两次实现具有相同的结果,并且实现了这两种形式。

List[,]
是列表的二维数组。您应该定义不能更改的“矩阵”大小。创建后,您可以在单元格中添加列表:

List<int>[,] matrix = new List<int>[2, 3]; // size is fixed
matrix[0, 1] = new List<int>(); // assign list to one of cells
matrix[0, 1].Add(42); // modify list items
List[,]matrix=新列表[2,3];//大小固定
矩阵[0,1]=新列表();//将列表分配给其中一个单元格
矩阵[0,1]。添加(42);//修改列表项
List
是一个列表列表。您有一个列表,其中包含作为项目的其他列表。它有一个维度,此维度的大小可以不同-您可以添加或删除内部列表:

List<List<int>> listOfLists = new List<List<int>>(); // size is not fixed
listOfLists.Add(new List<int>()); // add list
listOfLists[0].Add(42); // single dimension
List listOfLists=new List();//大小不固定
添加(new List());//添加列表
列表[0]。添加(42);//单个维度
它们是不同的数据结构

实际上,对于
List
类型的项,您的问题过于复杂。任何类型的
T
的结构都将保持不变。因此,这里有二维数组
T[,]
和List
List
。如上所述,它们是完全不同的数据结构。

List[,]
是整数列表的二维数组

List
是整数列表的列表

所以它们是完全不同的。共同点是它们都包含整数列表(
List
),但其中一个是二维数组。另一个是整数列表的单个列表。

List[,]
List
的二维数组。这意味着它有三个维度(其中两个是固定的).
List
是一个列表列表,所以有两个维度。所以比较它们没有多大意义

更好的比较方法是类似于
List[]
vs
List
。两者都是二维整数集合,但前者的一维是固定的,而后者可以在两个维度上展开

List<int>        A collection of integers which will grow as needed
int[]            An array of ints that will have a fixed length
List<int>[]      An array of List<int> which has a fixed number of List<int>, 
                 but each List<int> will expand as needed (by adding ints)
List<List<int>>  A list of list which can grow both by adding more List<int>
                 and by adding ints to one of the List<int>
int[,]           A 2d array of ints that is fixed in both dimensions and rectangular 
                 (i.e. length in both dimensions is always the same)
int[][]          An array of int[], i.e. a jagged array. Fixed in both dimensions but each
                 int[] can have a different length
列出将根据需要增长的整数集合
int[]具有固定长度的int数组
List[]具有固定数量列表的列表数组,
但每个列表将根据需要扩展(通过添加int)
列出一个列表,通过添加更多列表,列表可以同时增长
通过向列表中的一个添加int
int[,]在维度和矩形中都固定的int的二维数组
(即,两个尺寸中的长度始终相同)
int[][]int[]的数组,即锯齿状数组。在两个维度上都固定,但每个维度都固定
int[]可以有不同的长度
我认为
列表[,]
更接近
列表
(因为每个维度都有三个维度;主要区别在于后者是锯齿状的,即每个列表可以有不同的大小)。