C# program to create and access a 1D jagged array which contains four 2D array elements with Tuples

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 369
//Example of Jagged Array and 2D Rectangular Array of Tuples
int[][,] sampleJaggedArrayWith2DRectangularArray = new int[4][,]
{
new int[,] { {1,2}, {3,4} },
new int[,] { {5,6}, {7,8}, {9,10} , {11,12}},
new int[,] { {14,15}, {16,17}, {18,19}, { 20, 21 } },
new int[,] { {22,23}, {24,25} , { 26, 27 }, { 28, 30 } }
};

//create an tuple of Jagged Array and 2D Rectangular Array
var jaggedArrayWith2DRectangularArrayTuple = Tuple.Create(sampleJaggedArrayWith2DRectangularArray);

//access the tuple of Jagged Array and 2D Rectangular Array created

//element of 2nd row 3rd column 2nd Element [ 10 ]
var elementOf2ndRow3rdColumn = jaggedArrayWith2DRectangularArrayTuple.Item1[1][2,1];

Comments or Responses

Login to post response