简体   繁体   English

如何在C#中将int值的集合添加到列表中

[英]How to add collection of int values into a List in c#

I created this arraylist: 我创建了这个数组列表:

List<int[]> arrayList_objects = new List<int[]>();

Now i want, that in the moment of a button push a 3*1 array of int is added, that is what i got: 现在我想要的是,在按下按钮的瞬间添加了3 * 1的int数组,这就是我得到的:

arrayList_objects.Add(int[](0,1,2))

well now it gives me a syntax error. 现在,它给了我一个语法错误。 Thank you for your effort. 感谢你的付出。

Just create a array list like this: 只需创建一个数组列表,如下所示:

List<int[]> arrayList = new List<int[]>();

or like this: 或像这样:

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

And then do whatever You want with this :) 然后做任何你想做的事情:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM