C#中的List数组 [英] An array of List in c#
本文介绍了C#中的List数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个列表数组.在c ++中,我喜欢:
I want to have an array of Lists. In c++ I do like:
List<int> a[100];
,它是100个列表的数组.每个列表可以包含许多元素.我不知道如何在C#中执行此操作.谁能帮我吗?
which is an array of 100 Lists. each list can contain many elements. I don't know how to do this in c#. Can anyone help me?
推荐答案
您这样做:
List<int>[] a = new List<int>[100];
现在您有了一个 List< int>
类型的数组,其中包含100个空引用.您必须创建列表并将其放入数组,例如:
Now you have an array of type List<int>
containing 100 null references. You have to create lists and put in the array, for example:
a[0] = new List<int>();
这篇关于C#中的List数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文