Array, C#, CSharp-Arrays, Dimension of Arrays, Rank Of Array

Find the rank of an array using c#

Introduction

In this article, I will discuss how to find the rank of an array using C#.  

Description

Here I will discuss how to determine the rank of an array, Rank of an array means how to state the dimension of an array. Here we will perform using C#. C# has a predefined Rank property by which we can find the Rank of an array.
 
Follow the below code for learning how to determine the dimension of an Array.
using System;

namespace ConsoleRankArray
{
    class RankArray
    { 
            public static void Main()
            {
                int[] dimOneArray = new int[10];
                int[,] dimTwoArray = new int[10, 3];
                int[][] jaggedArray = new int[5][];

                Console.WriteLine(dimOneArray.Rank);
                Console.WriteLine(dimTwoArray.Rank);
                Console.WriteLine(jaggedArray.Rank);
            }
    }
}
Output
1 dimension(s)
2 dimension(s)
1 dimension(s)

SUMMARY

In this article, I discussed how we can determine the dimension of the array. This article will help full to find out the dimension of an array. Happy to helping you 😊

About Bidyasagar Mishra

Leave a Reply

Your email address will not be published. Required fields are marked *