You are on page 1of 6

arr[0]

int[] arr;
arr arr[1]
• new
arr[1]

arr = new int[3];

arr = new int[size];


Array Initialization
int[] arr = new int[] { 10, 50, 3 };
arr

int[,] arr; // two dim array


int[,,] arr; // three dim array
arr [0,0]
arr [1,3]
arr = new int[3, 5]; // 3 rows, 5 columns

int[,] arr = new int[,] {


{1,2,3},
{3,4,5}
}; // 2 rows, 3 columns
arr = new int[]{5,7,2};
Array.Sort(arr); // Static Method

arr = new int[]{5,7,2};


arr. GetLength (int dimension )
// normal Method
1 2 3 4

4 5
arr

10 15 20

int [][]arr = new int [3][];

int[][] jArray = new int[2][]; int[][] jArray = new int[2][] {


jArray[0] = new int[4] { 1, 2, 3 ,4 }; new int[4] { 1, 2, 3 ,4 },
jArray[1] = new int[2] { 4, 5}; new int[2] { 4, 5},
jArray[2] = new int[3] { 10, 15, 20}; new int[3] { 10, 15, 20}
};
int[][,] arr = new int[3][,]; // can include three two-dimensional arrays
Assignments

You might also like