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

Py2neo cypher query return instance method

neo4j cypher py2neo

Using the py2neo tutorial (http://book.py2neo.org/en/latest/cypher/):

Oracle DDL in autonomous transaction

oracle transactions constraints ddl ora-00054

I need to execute a bunch of (up to ~1000000) sql statements on an Oracle database. These statements should result in a referentially consistent state at the end, and all the statements should be r...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.