Override the GetHashCode method from object : Hash Code « Class « C# / CSharp Tutorial






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








7.49.Hash Code
7.49.1.Override the GetHashCode method from object