Initialize a two-dimensional array : Multi Dimensional Array : Data Structure C# Examples


C# Examples » Data Structure » Multi Dimensional Array »

 

Initialize a two-dimensional array









    
using  System;  
  
class  MainClass  {    
    public  static  void  Main()  {    
        int[,]  sqrs  =  {  
            {  1,  1  },  
            {  2,  4  },  
            {  3,  9  },  
            {  4,  16  },  
            {  5,  25  },  
            {  6,  36  },  
            {  7,  49  },  
            {  8,  64  },  
            {  9,  81  },  
            {  10,  100  }  
        };  
        int  i,  j;  
  
        for(i=0;  i  <  10;  i++)  {    
            for(j=0;  j  <  2;  j++)    
                Console.Write(sqrs[i,j]  +  "  ");      
            Console.WriteLine();    
        }    
    }    
}
    
   
  
   



Output

1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Multi Dimensional Array