C# program to create a 2-D rectangular array of Tuple

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 375
Tuple<int, int>[,] int2DArray = new Tuple<int, int>[2, 3];//creating an array of capacity 2,3

//Pushing data to the 2D Rectangular Array
for (int row = 0; row < 2; row++)
{
for (int col = 0; col < 3; col++)
{
int2DArray[row,col] = Tuple.Create((row+1),(col+1));
}
}

//Accessing data from the 2D Rectangular Array
for (int row = 0; row < 2; row++)
{
for (int col = 0; col < 3; col++)
{
Console.WriteLine($"Element at row {row} is {int2DArray[row, col].Item1} and col {col} is {int2DArray[row, col].Item2} ");
}
}

Comments or Responses

Login to post response