+ 1

About Jagged Arrays in C#

I am confused about initialization and declaration of jagged arrays. First of all: int[] array=new int[3]{0,1}; Console.WriteLine(array[2]); When I execute the above commands in C, it gives 0. It means C automatically initialize all array element that is not initialized by the user to 0. But when I try to do this with jagged arrays: new int[3]{0,1} Console.WriteLine(jaggedArr[0][2]); It gives an error like that: expected length of array '3'. Second: int[][]jaggedArray=new int[3][4]//I can specify the value of arrays. But I can't specify(I can't use 4) the elements of array. I should specify it, when I go into curly braces. Am I right or wrong?

13th Jan 2018, 8:52 PM
Yusuf
Yusuf - avatar
1 Réponse
0
14th Jan 2018, 9:54 PM
sneeze
sneeze - avatar