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?
-
int[ , ] a; a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};
-
int[ , ] a; a = new int[2, 3]{};
-
int[ , ] a = {{7, 1, 3}, {2, 9,6 }};
-
int[ , ] a; a = new int[1, 2];
-
int[ , ] a; a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};
Discussion:
4 comments Page 1 of 1.
Vinothkumar said:
8 years ago
I think braces will not be empty because it contains array elements.
Sayali said:
9 years ago
Why 2nd option is wrong?
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.
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.
Nik said:
1 decade ago
Can any one tell me how it is correct answer?
Thanks in advance.
Thanks in advance.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers