Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
Examples of errors detected by the...

Examples of errors detected by the V3126 diagnostic

V3126. Type implementing IEquatable<T> interface does not override 'GetHashCode' method.


NBitcoin

V3126 Type 'MoneyBag' implementing IEquatable<T> interface does not override 'GetHashCode' method. Money.cs 78


public class MoneyBag : IMoney,
                        IEnumerable<IMoney>,
                        IEquatable<MoneyBag>
{
  ....
  public bool Equals(MoneyBag other)
  {
    return Equals(other as IMoney);
  }

  public bool Equals(IMoney other)
  {
    if (other is null)
      return false;
    var m = new MoneyBag(other);
    return m._bag.SequenceEqual(_bag);
  }
  ....
}