Definitions
Arrays which have more than one dimension; these arrays-of-arrays are called multidimensional arrays. They are very similar to standard arrays with the exception that they have multiple sets of square brackets after the array variable.
step
- Go to Solution explorer and open console project.
- Add new class.
- using System;
- public class JaggedArray
- {
- static void Main()
- {
- int[][] jaggedArr = new int[][]
- {
- new int[]
- {
- 1,2
- },
- new int[]
- {
- 1,2,3
-
- },
- new int[]
- {
- 1,2,3,4
-
- }
- };
- foreach(int[] array in jaggedArr)
- {
- foreach(int e in array)
- {
- Console.Write(e + " ");
- }
- }
- Console.Write('\n');
- }
- }
- Console.WriteLine(array[0, 1]);
- Console.WriteLine(array[1, 0]);
- Console.WriteLine(array[1, 1]);
- Console.ReadLine();
- }
- }