//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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.