c++ ##_##
int [,,]arr = new int[2,2,3];
Console.WriteLine(arr.Length);
Correct answer: 2
12
In the above code snippet, we are creating a 3-Dimensional array, then the length of the array will be 2 x 2 x 3 = 12
byte [][][]arr = new byte[2][][];
It will create a 3-D jagged array that contains 2 2-D jagged arrays.
It will create a 3-D jagged array that contains 3 2-D jagged arrays.
It will create a 2-D jagged array that contains 2 2-D jagged arrays
Correct answer: 1
It will create a 3-D jagged array that contains 2 2-D jagged arrays.
The first option is correct about the above code.
正确答案:1
它将创建一个包含2个2D锯齿阵列的3D锯齿阵列。
关于上述代码,第一个选项是正确的。
int []arr = {1,2,3,4,5};
Correct answer: 3
arr.Length;
The Length property is used to get the total number of elements in an array.
正确答案:3
长度
Length属性用于获取数组中元素的总数。
Correct answer: 3
0
In C#.NET, 0 is the default value of array elements.
static void Main(string[] args)
{
int[] a = new int[5];
a[1] = 2;
a[3] = 4;
Console.WriteLine(a[0] + "," + a[1] + "," + a[2] + "," + a[3] + "," + a[4]);
}
Correct answer: 1
0,2,0,4,0
In the code, only index 1 and 3 are assigned with the 2 and 4, rest all elements contain the default values (0).
正确答案:1
0,2,0,4,0
在代码中,只有索引1和3被分配了2和4,其余所有元素都包含默认值(0)。
翻译自: https://www.includehelp.com/dot-net/csharp-arrays-aptitude-questions-and-answers-2.aspx
c++ ##_##