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));
3
4
7
9
2
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
5 comments Page 1 of 1.

Parvez said:   1 decade ago
Here getupperbound determines the maximum index of an array, getupperbound = length of array -1.

See said:   1 decade ago
Upper bound is 2 because elements are 3. a[0], a[1], a[2]. So 2 is upper bound.

Santhosh said:   1 decade ago
getUpperBound(0) gives number of elements in a[1] array, So answer will be 2.

Thanmayi said:   1 decade ago
In getUpperBound(0), 0 refers to single dimension array.

Sunil yadav said:   1 decade ago
Please tell us how the correct answer is 2 ?

Post your comments here:

Your comments will be displayed after verification.