下面的代码在VS2015.2中编译,但在升级到VS2015.3后,它失败了error CS0019: Operator '==' cannot be applied to operands of type 'Registration<Something>' and 'Something'
。
public class Class1
{
public Class1()
{
var a = new Registration<Something>();
var x = a == Something.Bad; // this line fails in VS2015.3
}
}
public struct Registration<T> where T:struct
{
public static implicit operator T?(Registration<T> registration)
{
return null;
}
}
public enum Something
{
Good,
Bad
}
我无法在更新3的更改日志中找到关于此类更改的任何通知。有人可以告诉我,为什么会发生这种情况?哪个是正确的行为?
编辑:隐式转换,等式运算符和nullables ...和枚举的组合。当T是枚举时,这似乎只会失败。