Comparing two Union<int, string>, where one is an int and the other is a string can result in equality being incorrectly reported, as exhibited via this code snippet:
var a = new Union<int, string>(0);
var b = new Union<int, string>("1234");
Assert.IsFalse(a.Equals(b));
The problem is that Union<int, string>("1234") will internally store the default value (0) for the int value and so the two match.
Comparing two Union<int, string>, where one is an int and the other is a string can result in equality being incorrectly reported, as exhibited via this code snippet:
The problem is that Union<int, string>("1234") will internally store the default value (0) for the
int
value and so the two match.