Override the GetHashCode method from object : Hash Code : Class C# Examples


C# Examples » Class » Hash Code »

 

Override the GetHashCode method from object









    
using  System;

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

        public  override  int  GetHashCode()  {
                return  (int)  Math.Sqrt(  Math.Pow(this.real,  2)  *  Math.Pow(this.imaginary,  2)  );
        }

        private  readonly  double  real;
        private  readonly  double  imaginary;
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Hash Code