The source code to find out the dimensions of the specified array is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
//Program to find out the dimensions of an array in C#
using System;
class Demo
{
static void Main(string[] args)
{
int[] OneD = new int[10] ;
int[,] TwoD = new int[3, 3];
int[,,] ThreeD = new int[2,3, 3];
Console.WriteLine("Dimensions of OneD array is : " + OneD.Rank);
Console.WriteLine("Demensions of TwoD array is : " + TwoD.Rank);
Console.WriteLine("Demensions of ThreeD array is : " + ThreeD.Rank);
}
}
Output:
Dimensions of OneD array is : 1
Demensions of TwoD array is : 2
Demensions of ThreeD array is : 3
Press any key to continue . . .
Explanation:
In the above program, we created three integer arrays OneD, TwoD, and ThreeD, and then we find out the dimensions of arrays using "Rank" property.
Program:
The source code to find out the dimensions of the specified array is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created three integer arrays OneD, TwoD, and ThreeD, and then we find out the dimensions of arrays using "Rank" property.
need an explanation for this answer? contact us directly to get an explanation for this answer