#129 – Initializing Jagged Arrays
October 24, 2010 Leave a comment
It’s possible to declare and initialize a jagged array all in one statement. Here’s an example:
int[][] nums2 = new int[3][] { new int[] { 1, 2, 3 }, new int[] { 4, 8 }, new int[] { 10, 20, 30, 40 } };
or
int[][] nums2 = { new int[] { 1, 2, 3 }, new int[] { 4, 8 }, new int[] { 10, 20, 30, 40 } };