//HI All what is wrong with this code,i try to declare 4 dim. array

int [, , ,] a =  new int [3,4] = {{2,3,4,5}, {34,56,25,67}, {22,44,55,77}};
//how do i declare it an assign values  to it?Thanks.

Recommended Answers

Get rid of the second "=" sign. Also your declarations don't match. You have 3 commas, then only 2 commas (and dimensions) in the intialization. The following should work:

int [,] a =  new int [3,4]  { {2,3,4,5}, {34,56,25,67}, {22,44,55,77} };
Jump to Post

All 4 Replies

Get rid of the second "=" sign. Also your declarations don't match. You have 3 commas, then only 2 commas (and dimensions) in the intialization. The following should work:

int [,] a =  new int [3,4]  { {2,3,4,5}, {34,56,25,67}, {22,44,55,77} };

3 rows,4 columns ,right? its 2 dimensional ? So for 4 dim,how many commas do i need?

Looks like you figured it out. One comma is 2 dimensions. Three commas are 4 dimensions. Ensure your initialization matches your declaration.

Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.