C# Programming - Arrays - Discussion

Discussion :: Arrays - General Questions (Q.No.6)

6. 

Which of the following is the correct output of the C#.NET code snippet given below?

    int[ , , ] a = new int[ 3, 2, 3 ]; 
    Console.WriteLine(a.Length);

[A]. 20
[B]. 4
[C]. 18
[D]. 10
[E]. 5

Answer: Option C

Explanation:

No answer description available for this question.

Mot said: (Jun 9, 2011)  
How the length is 18 ? I m not getting.

Shyam said: (Oct 31, 2011)  
3*2*3=18;

Yakesh said: (Jul 11, 2012)  
1) Here length method gives the capacity of an array or no. Of elements it can store.

2) 3 arrays every array with 6 elements (2 by 3 array). Two rows and three columns.

Neha said: (Dec 19, 2013)  
How's it will be 18?

Moinak said: (Jan 9, 2014)  
3 arrays and if every array has 6 elements the total number of elements = 3*6 = 18. I think this is the answer.

Avdhut said: (Feb 2, 2014)  
It is 3d array so total 9 element so every element take 2 byte size because it is int type array so answer is 18.

Mr. Az said: (Jul 9, 2014)  
Well, its because; it is a 3D array with dimensions 3,2,3 so simply its get multiplied 3*2*3 = 18 i.e: Option C.

Note: In C# int requires 4 bytes of memory.

Nik said: (Nov 11, 2014)  
It is third dimension array right?

Then how can we decide it's length as 18?

Yash said: (Dec 24, 2015)  
I am not getting this at all. Can anyone please explain how 3D array looks like and how come its 18?

Sum said: (Oct 19, 2016)  
3D array means 3 dimensional you can see the question in the square braces two commas is there that's the reason its called 3 dimesion array and 18 is the answer simply multiplied.

Prem said: (Sep 15, 2018)  
The answer is 4.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.