effective C#

Equals()のオーバーライド

public class Foo : IEquatable<Foo> { public override bool Equals(object other) { // nullチェック if (object.ReferenceEquals.(other, null)) { return false; } if (object.ReferenceEquals(this, other)) { return true; } if (this.GetType() != other.G</foo>…

標準的なSystem.Object.Equals()のオーバーライド実装

public class Foo : IEquatable<Foo> { public override bool Equals(object right) { //nullチェック if (Object.ReferenceEquals(right, null)) return false; if (Object.ReferenceEquals(this, right)) return true; if (this.GetType() != right.GetType()) </foo>…