c++ ##_##
Correct answer: 4
Using a for each loop
In C#.NET, using a foreach loop, we can access each element of an array without using the index variable.
正确答案:4
为每个循环使用
在C#.NET中,使用foreach循环,我们无需使用index变量即可访问数组的每个元素。
int []arr; arr = new int[3]; arr[0]=1; arr[1]=1; arr[2]=1;
int []arr; arr = new int {1,2,3};
Options:
Correct answer: 4
A, B, D
A, B and D are the correct ways to initialize an array of an integer with 3 elements.
-
int [ ] arr ; arr = new int [ 3 ] ; arr [ 0 ] = 1 ; arr [ 1 ] = 1 ; arr [ 2 ] = 1 ;
-
int [ ] arr ; arr = new int { 1 , 2 , 3 } ;
选项:
正确答案:4
A,B,D
A,B和D是初始化具有3个元素的整数数组的正确方法。
static void Main(string[] args)
{
int[] ARR = {1,2,3,4,5};
foreach (int X in ARR)
{
Console.Write(X + " ");
}
}
Correct answer: 1
1 2 3 4 5
The above code will print "1 2 3 4 5" on console screen.
正确答案:1
1 2 3 4 5
上面的代码将在控制台屏幕上显示“ 1 2 3 4 5” 。
Correct answer: 1
Yes
Yes, we can increase the size of the already created array.
static void Main(string[] args)
{
int[] ARR = {1,2};
ARR = new int[4];
foreach (int X in ARR)
{
Console.Write(X + " ");
}
}
Correct answer: 2
0 0 0 0
The above code will print "0 0 0 0" on console screen.
翻译自: https://www.includehelp.com/dot-net/csharp-arrays-aptitude-questions-and-answers-3.aspx
c++ ##_##