Q
c#中的列表数组
32
A
回答
62
你这样做:
List<int>[] a = new List<int>[100];
现在你有一个包含100个空引用类型List<int>
的数组。你必须创建列表,并把数组中,例如:
a[0] = new List<int>();
1
List<int>[] a = new List<int>[100];
你仍然要在阵列中分配每个人名单,然后才能,虽然使用它:
for (int i = 0; i < a.Length; i++)
a[i] = new List<int>();
1
使用
List<int>[] a = new List<int>[100];
6
简单的方法:
List<int>[] a = new List<int>[100];
for (int i = 0; i < a.Length; i++)
{
a[i] = new List<int>();
}
或LINQ
应用程序罗奇
var b = Enumerable.Range(0,100).Select((i)=>new List<int>()).ToArray();
12
由于没有上下文被赋予这个问题,你是一个相对较新的用户,我想确保你都知道,你可以有列表的列表。这是不一样的列表的数组,就特别针对该要求,但仍:
List<List<int>> myList = new List<List<int>>();
您可以通过集合初始化初始化它们像这样:
List<List<int>> myList = new List<List<int>>(){{1,2,3},{4,5,6},{7,8,9}};
-6
// The letter "t" is usually letter "i"//
for(t=0;t<x[t];t++)
{
printf(" %2d || %7d \n ",t,x[t]);
}
+0
您可能想解释一下你的答案。它似乎也没有解决这个问题,即问如何创建一个列表数组,而不是如何打印出任何东西。 –
相关问题
- 1. C中的数组列表#
- 2. 在C中的数组keyvaluepair的列表#
- 3. C和JNI数组列表
- 4. JSON数组到C#列表
- 5. C#数组列表ArrayList
- 6. 将列表中的asp.net mvc c#列表转换为javascript数组
- 7. 数组列表存储到在c#另一个数组列表
- 8. 在c#unity中定义数组列表。
- 9. 将整数列表读入数组C++
- 10. c#搜索整数数组列表
- 11. 顺序,组和总结ExpandoObject中的数组列表c#
- 12. 数组列表中的参数并传递给新函数? C
- 13. Java中的数组列表
- 14. r中的列表数组
- 15. 反序列化json数组列表中的c#
- 16. 在c中有n行四列的数组列表#
- 17. 将数据列表转换为2d数组或列表中的c#
- 18. c#:将ID为数组的列表移动到列表顶部
- 19. 组织基于整数列表的字符串列表c#
- 20. 从数组列表中获取固定数量的项目c#
- 21. C#使用数组中的数据填充列图表
- 22. 将整数转换为组合框中的数字列表 - C#
- 23. C++中的n元组列表
- 24. 将列表组合到列表列表中(C#)
- 25. 数组到链接列表C
- 26. C#列表到数组问题
- 27. 打印链接列表数组C++
- 28. Unity c#数组vs静态列表
- 29. QJsonDocument列表或数组在c + +
- 30. Objective-C数组/列表问题
+1的初始化程序语法(它适用于数组以及列表) – phoog