Array sizes and dimensions. : Array Length : Data Structure C# Examples


C# Examples » Data Structure » Array Length »

 

Array sizes and dimensions.









    
using  System;

class  MainClass  {

        public  static  void  PrintArray(int[]  arr)  {
                for  (int  i  =  0;  i  <  arr.Length;  ++i)
                        Console.WriteLine("OneDArray  Row  {0}  =  {1}",  i,  arr[i]);
        }

        public  static  void  PrintArrayRank(int[,]  arr)  {
                Console.WriteLine("PrintArrayRank:  {0}  dimensions",  arr.Rank);
        }


        public  static  void  Main()  {
                int[]  x  =  new  int[10];
                for  (int  i  =  0;  i  <  10;  ++i)
                        x[i]  =  i;
                PrintArray(x);

                int[,]  y  =  new  int[10,  20];
                for  (int  k  =  0;  k  <  10;  ++k)
                        for  (int  i  =  0;  i  <  20;  ++i)
                                y[k,  i]  =  i  *  k;
                PrintArrayRank(y);
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Array Length