0
//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.
2
Contributors
4
Replies
18
Views
3 Years
Discussion Span
Last Post by aluhnev
0

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} };
0

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

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.