Skip to content
Mario Gutierrez edited this page Jan 7, 2017 · 6 revisions

Various ways to initialize.

int[] a = {1, 2, 3};
int[] b = new int[] {1, 2, 3};
int[] c = new int[3];

Implicitly-typed

var a = new[] {1, 2, 3};

Matrices

int[,] mat = new int[3, 4];

Jagged Arrays

int[][] jag = new int[3][];
for (int i = 0; i < 3; ++i)
{
  jag[i] = new int[4];
}
Clone this wiki locally