The array in C # is a reference type, and C # defines an integer array as follows:
int [] Intarray = {A-i}; or int [] Intarray = new INT[10];
The way to define an integer array in C + + is:
int intarray[] = {n/a}; or int * Intarray = new INT[10];
C # defines an integral array that can be one-dimensional or multidimensional, and also support matrices and jagged arrays.
Note: The way to define a multidimensional array (matrix) is [,] and the way to define multidimensional "jagged matrices" is []. In addition, the use of the new keyword does not necessarily mean that the object is dynamically allocated (into the stack).
Here is a common definition of a (one-dimensional) multidimensional array in C #:
int []A1; Defining a one-dimensional array
int [,]A2; Defining a two-dimensional array
int [,,]a3; Defining three-dimensional arrays
int []A1 = new int [10]; Defining a one-dimensional array depth
int [,]A2 = new int [10,20]; Defining two-dimensional array depth
int [,,]a3 = new int [10,20,30]; Defining three-bit array depth
int []A1 = new int []{1,2,3}; Initialization
int [,]A2 = new int [,]{{1,2,3},{4,5,6}};
You can also define an array of "jagged":
int [][]var = new int [3][];
Var[0] = new int[]{1,2,3};
VAR[1] = new int[]{1,2,3,4,5,6};
VAR[2] = new int[]{1,2,3,4,5,6,7,8,9};
Note that the difference between int [,]a, and int [][]a: The former defines a two-dimensional fixed array, which defines a two-dimensional mutable array. Only they have not yet been allocated space and initialized. int [][]var = new int[3][4]; it's wrong.
The following error:
Class Test
{
static void F (int []arr) {}
static void Main ()
{
F ({A-i});//Error! {A-i} is not a valid expression.
}
}
Class Test
{
STATCI void F (int []arr) {}
static void Main ()
{
F (new int []{1,2,3});
}
}
The above describes C # defining an integral array