Definite Assignment and Array of struct : Struct array : Struct C# Examples


C# Examples » Struct » Struct array »

 

Definite Assignment and Array of struct









    
using  System;
struct  Complex
{
        public  Complex(float  real,  float  imaginary)  
        {
                this.real  =  real;
                this.imaginary  =  imaginary;
        }
        public  override  string  ToString()
        {
                return(String.Format("({0},  {0})",  real,  imaginary));
        }
        
        public  float        real;
        public  float        imaginary;
}

class  MainClass
{
        public  static  void  Main()
        {
                Complex[]        arr  =  new  Complex[10];
                Console.WriteLine("Element  5:  {0}",  arr[5]);                //  legal
        }
}
    
   
  
   



Output

Element 5: (0, 0)


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Struct
» Struct array