Example 1: c# two dimensional array
int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
int[,] array2Da = new int[4, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
string[,] array2Db = new string[3, 2] { { "one", "two" }, { "three", "four" },
{ "five", "six" } };
int[, ,] array3D = new int[,,] { { { 1, 2, 3 }, { 4, 5, 6 } },
{ { 7, 8, 9 }, { 10, 11, 12 } } };
int[, ,] array3Da = new int[2, 2, 3]
{ { { 1, 2, 3 }, { 4, 5, 6 } },{ { 7, 8, 9 }, { 10, 11, 12 } } };
Example 2: C# public 2d array
public class Globals
{
public static string[,] tableArray;
}
Globals.tableArray = new string[rowLength,colLength];
Example 3: initialize matrix c#
int[,] matrix = new int[10,9];