Multidimensional array init without pre-existing values?

How can we initialize a multidimensional array without pre-existing values? Only the third one is correct, but it works with pre-existing values. I would like my multidimensional array to contain 10 or 20 values, and add them later on with numbers[y][x] :

int[][] numbers = new int[10][];
//List<int[]> numbers = new List<int[]>();
//int[10][]{ new int[]{}};
//correct :  { new int[] {1, 2}, new int[] {3, 4, 5} };
numbers[0][0] = 58;

Would you know how to do this? (I don't know if [,] is the same as [][] by the way)

Thanks

Answers


Would you know how to do this? (I don't know if [,] is the same as [][] by the way) there are not the some as int[][] test = new int[10][]; is called a jagged array (array of arrays) and int[,] is a fixed array

just declare your array as the following

 int[,] test = new int[10,30];    
test[0,1] = 10;
test[1,2] = 20;

You can try initiating values this way, it is one way to create jagged-array

int[][] test = new int[10][];
test[0] = new int[20];
test[1] = new int[30];
test[2] = new[] { 3, 4, 5 };

test[0][1] = 10;
test[1][2] = 20;

Need Your Help

Have a correct datetime with correct timezone

python datetime rss feedparser

I am using feedparser in order to get RSS data.

TypeError when trying to upload Pictures from Google App Engine to Picasa with the GData API

python google-app-engine gdata-api typeerror picasa

I'm trying to write a small tool to upload Pictures from Google App Engine to Picasa. Fetching the image works, but when i try to upload it i get the error "TypeError: stat() argument 1 must be (en...