October 12, 2017
Jagged Arrays
Using Jagged Arrays, we can define any number of columns within a row of a two/multi-dimensional array.
Here is an example:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; using System.Collections; namespace ConsoleApplication6 { class Program { static void Main(string[] args) { int[][] jagged = new int[3][]; jagged[0] = new int[2] { 10, 20 }; jagged[1] = new int[6] { 30, 40, 50, 60, 70, 80 }; jagged[2] = new int[3] { 90, 100, 110 }; //Console.WriteLine(sizeof(int)*(2+6+3)); for (int row = 0; row < jagged.Length; row++) { for(int col=0; col< jagged[row].Length; col++) { Console.Write(jagged[row][col] + " "); } Console.WriteLine(); } } } }