From 70c41415f158944a406e80f987c2e0bf8c9cd75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20H=C3=BCbner?= Date: Sat, 28 Nov 2020 16:25:17 +0100 Subject: [PATCH] add == and != operator overload to avoid comparing underlying values without considering TThis --- ValueOf/ValueOf.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ValueOf/ValueOf.cs b/ValueOf/ValueOf.cs index 81993d3..04299d7 100644 --- a/ValueOf/ValueOf.cs +++ b/ValueOf/ValueOf.cs @@ -82,6 +82,16 @@ public override int GetHashCode() return !(a == b); } + public static bool operator ==(ValueOf a, object b) + { + return b is TThis other && a == other; + } + + public static bool operator !=(ValueOf a, object b) + { + return !(a == b); + } + public static implicit operator TValue(ValueOf a) { return a.Value;