Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Declaring and using multidimensional array in C#

Example:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace ForgetCode
  7. {
  8. public class MainClass
  9. {
  10. public static void Main()
  11. {
  12.  
  13. // Multidimensional arrays.
  14. int[,] numbers = new int[3, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
  15. string[,] siblings = new string[2, 2] { { "Mike", "Amy" }, { "Mary", "Albert" } };
  16.  
  17. //Omitting size
  18. int[,] numbers2 = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
  19. string[,] siblings2 = new string[,] { { "Mike", "Amy" }, { "Mary", "Albert" } };
  20.  
  21. //Without New operator
  22. int[,] numbers3 = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
  23. string[,] siblings3 = { { "Mike", "Amy" }, { "Mary", "Albert" } };
  24. }
  25. }
  26. }