How to create an List of int arrays? [closed]

I want to create a list and each element of it is an array, similarly to an array of structs in C language. Can it be done in c# and how if it can? Thanks very much!

Wrong: List<int[]> arrayList = new List<int[]>;

1

3 Answers

You're missing parenthesis at the end of your new clause.

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

0

If you know your starting values you can also initialize it like so:

List<int[]> arrayList = new List<int[]> { new int[] { 1, 2, 3, 4 }, new int[] { val1, val2, val3 }, otherIntArray }; 
List<Int[]> arrList = new List<Int[]>(); int[] ArrayOfInts = new int[10]; 

fill as required

arrList.Add(ArrayOfInts); 

You Might Also Like