For a reference type (class) like Point3 (for example), is this an overkill, lacking:
#region System.Object Members
public override bool Equals ( object obj )
{
//return this == ( Point3 ) obj;
if ( obj == null )
{
return false;
}
if ( this.GetType ( ) != obj.GetType ( ) )
{
return false;
}
return this.Equals ( ( Point3 ) obj );
}
public override int GetHashCode ( )
{
return this.X.GetHashCode ( ) ^ this.Y.GetHashCode ( ) ^ this.Z.GetHashCode ( );
}
public override string ToString ( )
{
return String.Format ( "[{0}, {1}, {2}]", this.X, this.Y, this.Z );
}
#endregion
#region IEquatable<Point3> Members
public bool Equals ( Point3 other )
{
if ( other == null )
{
return false;
}
if ( ReferenceEquals ( this, other ) )
{
return true;
}
if ( this.GetHashCode ( ) != other.GetHashCode ( ) )
{
return false;
}
if ( !base.Equals ( other ) )
{
return false;
}
return this == other;
}
#endregion
public static bool operator == ( Point3 v0, Point3 v1 )
{
return ( v0.X.IsEqual ( v1.X ) ) && ( v0.Y.IsEqual ( v1.Y ) ) && ( v0.Z.IsEqual ( v1.Z ) );
}
public static bool operator != ( Point3 v0, Point3 v1 )
{
return !( v0 == v1 );
}
Please make adjustments or post a new one for both value and reference types, that I can use in my base types (value and reference) without thinking too much every time I implement it again.
EDIT: This is for immutable types.