Microsoft Certified Solutions Developer (MCSD) Certification Practice Test

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for the Microsoft Certified Solutions Developer Certification Test. Use multiple choice quizzes with hints and explanations to boost your readiness. Excel on your test!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


How do you define a multi-dimensional array in C#?

  1. int[] array = new int[3,5];

  2. int[,,] array = new int[3,5];

  3. int[,] array = new int[3,5];

  4. int[][] array = new int[3][5];

The correct answer is: int[,] array = new int[3,5];

In C#, a multi-dimensional array is defined using commas to specify the different dimensions of the array. The correct way to define a two-dimensional array is by using a syntax that includes a comma between the dimensions, as seen in the chosen answer. Specifically, `int[,] array = new int[3,5];` creates a two-dimensional array with three rows and five columns. This syntax is significant because it clearly indicates that the array has a rectangular shape, where each row contains the same number of elements. The use of the comma denotes the presence of multiple dimensions, thus distinguishing it from single-dimensional arrays or jagged arrays, which are defined differently. In contrast, defining a multi-dimensional array with other options reveals incorrect approaches: for example, using three commas would suggest a three-dimensional array but lacks clarity and proper initialization. Furthermore, jagged arrays, defined with double brackets (e.g., `int[][]`), represent an array of arrays rather than a true multi-dimensional structure, which is crucial to understand for distinguishing these concepts in C#.