C# Programming - Arrays - Discussion
Discussion Forum : Arrays - General Questions (Q.No. 13)
13.
Which of the following is the correct output of the C#.NET code snippet given below?
int[][] a = new int[2][];
a[0] = new int[4]{6, 1, 4, 3};
a[1] = new int[3]{9, 2, 7};
Console.WriteLine(a[1].GetUpperBound(0));Discussion:
5 comments Page 1 of 1.
Sunil yadav said:
1 decade ago
Please tell us how the correct answer is 2 ?
Parvez said:
1 decade ago
Here getupperbound determines the maximum index of an array, getupperbound = length of array -1.
Thanmayi said:
1 decade ago
In getUpperBound(0), 0 refers to single dimension array.
Santhosh said:
1 decade ago
getUpperBound(0) gives number of elements in a[1] array, So answer will be 2.
See said:
1 decade ago
Upper bound is 2 because elements are 3. a[0], a[1], a[2]. So 2 is upper bound.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers