C# Creating an array of arrays

前端 未结 4 1915
终归单人心
终归单人心 2020-11-30 07:33

I\'m trying to create an array of arrays that will be using repeated data, something like below:

int[] list1 = new int[4] { 1, 2, 3, 4 };
int[] list2 = new i         


        
4条回答
  •  一生所求
    2020-11-30 07:48

    I think you may be looking for Jagged Arrays, which are different from multi-dimensional arrays (as you are using in your example) in C#. Converting the arrays in your declarations to jagged arrays should make it work. However, you'll still need to use two loops to iterate over all the items in the 2D jagged array.

提交回复
热议问题