C# Programming - Arrays - Discussion

Discussion Forum : Arrays - General Questions (Q.No. 9)
9.
Which of the following are the correct ways to define an array of 2 rows and 3 columns?
  1. int[ , ] a;
    a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};
  2. int[ , ] a;
    a = new int[2, 3]{};
  3. int[ , ] a = {{7, 1, 3}, {2, 9,6 }};
  4. int[ , ] a;
    a = new int[1, 2];
  5. int[ , ] a;
    a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};
1, 2 , 3
1, 3
2, 3
2, 4, 5
4, 5
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Samir said:   10 years ago
int[ , ] a;

a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};

Here [2,3] 2 rows and 3 column and initialize also done there .


int[ , ] a = {{7, 1, 3}, {2, 9,6 }};

Here initialize done here in 1st row 3 element and 2nd row 3.

Vinothkumar said:   8 years ago
I think braces will not be empty because it contains array elements.

Nik said:   1 decade ago
Can any one tell me how it is correct answer?

Thanks in advance.

Sayali said:   9 years ago
Why 2nd option is wrong?

Post your comments here:

Your comments will be displayed after verification.