How to find rank of an array using c#

Introduction

Here I will discuss how we can find the rank of an array using the C# language.

Array 

You have to know the below points about Array Before finding the rank of an array.

  • The array is a collection of similar types of data.
  • It stores in a sequential way.
  • Array size is always fixed.

Rank of an array

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 I 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 or rank of an array. If you find helpful information from this article, please share it with your colleagues and the development community. Happy to help you 😊.

1 thought on “How to find rank of an array using c#”

Leave a Comment

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