Examveda

Which is the correct way of defining and initializing an array of 3 integers?

A.

int[] a={78, 54};

B.

int[] a;
a = new int[3];
a[1] = 78;
a[2] = 9;
a[3] = 54;

C.

int[] a;
a = new int{78, 9, 54};

D.

int[] a;
a = new int[3]{78, 9, 54};

Answer: Option D


Join The Discussion

Related Questions on Arrays and Strings in C Sharp