I identified this oddity today in the original source for the .NET Framework, and I wonder if the answer will lead to an interesting regional case in the implementation.
The implementation Enum.CompareTo()includes an explicit check this==null:
public int CompareTo(Object target)
{
if (this == null)
throw new NullReferenceException();
Contract.EndContractBlock();
}
Full source: http://referencesource.microsoft.com/mscorlib/system/enum.cs.html#b50f2b9e3118e0d6
Why does this code need to be checked for null ?
I would expect the mode itself to take care of this - and really write a lot of code under this assumption.
source
share