Csharp/CSharp Tutorial/Class/Hash Code
Версия от 15:31, 26 мая 2010; (обсуждение)
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;
}