According to Microsoft's documentation, I can compare value types with null, by marking them nullable. This is particularly useful when using null-propagation in nested objects.
However, when comparing specific enums, which I thought were value-types, I can still compare with null, like this:
public class NullColorComparer
{
public bool CompareNullWithColor()
{
// This return false.
return null == Color.Red;
}
}
public enum Color
{
Red,
Blue
}
Why does this work? Shouldn't compilation fail with a type error?