Use this to reference struct's constructor : struct initialization « struct « C# / CSharp Tutorial






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 );
   }
}








6.4.struct initialization
6.4.1.How to initialize a structure
6.4.2.Use this to reference struct's constructor