Q:

C# program to find out the dimensions of an array

belongs to collection: C# Basic Programs | array programs

0

C# program to find out the dimensions of an array

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

//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 OneDTwoD, 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

total answers (1)

C# Basic Programs | array programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to demonstrate the example of BlockCopy... >>
<< C# program to print the lower bound and upper boun...