Use this to reference struct's constructor : Struct initialization : Struct C# Examples


C# Examples » Struct » Struct initialization »

 

Use this to reference struct's constructor









    
public  struct  ComplexNumber
{
      public  ComplexNumber(  double  real,  double  imaginary  )
      {
            this.real  =  real;
            this.imaginary  =  imaginary;
      }

      public  ComplexNumber(  double  real  ):this(  real,  0  )
      {
            this.real  =  real;
      }

      private  double  real;
      private  double  imaginary;
}

public  class  MainClass
{
      static  void  Main()
      {
            ComplexNumber  valA  =  new  ComplexNumber(  1,  2  );
      }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Struct
» Struct initialization