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

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 1135
//Creating an array of capacity 10
Tuple<int>[] int1DArray = new Tuple<int>[10];

//Pushing data to the 1D Rectangular Array
for (int i = 10; i--> 0;){
int1DArray[i] = Tuple.Create(10 * i);
}

//Accessing data from the 1D Rectangular Array
for (int i = 10; 0 <-- i){
Console.WriteLine($"Element at {i} is {int1DArray[i].Item1} ");
}


First we have created a 1D array of Tuple whose capacity is 10. We can figure out that we are not using the () for instantiating it. Once the Tuple is created, we have pushed some values to the Tuple-Array by using the "goes to" operator. Finally we are reading the data from the Tuple-Array by using the "is approached by" operator.

Comments or Responses

Login to post response