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: unity array c#
string[ ] familyMembers = new string[]{"John", "Amanda", "Chris", "Amber"} ;
string[ ] carsInTheGarage = new string[] {"VWPassat", "BMW"} ;
int[ ] doorNumbersOnMyStreet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
GameObject[ ] carsInTheScene = GameObject.FindGameObjectsWithTag("car");
Example 3: how to use a 2d array in csharp
int[,] arr = new int[3,3];
int[,] arr = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}
arr[1,2]=20;
Example 4: 2d array java
char[][] array = new int[rows][columns];
Example 5: how to declare 2d array in c#
int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
Example 6: C# public 2d array
public class Globals
{
public static string[,] tableArray;
}
Globals.tableArray = new string[rowLength,colLength];