Sep 20, 2011

C# program to count the total numbers of dimension of given array

using System;

namespace arrayDemo
{
    class Program
    {
       unsafe static void Main(string[] args)
        {
          
           int[,] arr={{1,2,3},{8,9,10}};
           int dimension;

           //To get the dimension of the array
           dimension = arr.Rank;

          //To print the value of count
           Console.WriteLine("Dimension of the array is: {0}", dimension);
           Console.ReadKey();
        }
    }
}

Output: Dimension of the array is: 2

No comments:

Post a Comment