public int CompareTo(Object target)
{
const int retIncompatibleMethodTables = 2; // indicates that the method tables did not match
const int retInvalidEnumType = 3; // indicates that the enum was of an unknown/unsupported unerlying type
if (this == null)
throw new NullReferenceException();
int ret = InternalCompareTo(this, target);
if (ret < retIncompatibleMethodTables)
{
// -1, 0 and 1 are the normal return codes
return ret;
}
else if (ret == retIncompatibleMethodTables)
{
Type thisType = this.GetType();
Type targetType = target.GetType();
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arg_EnumAndObjectMustBeSameType"),
targetType.ToString(), thisType.ToString()));
}
else
{
// assert valid return code (3)
BCLDebug.Assert(ret == retInvalidEnumType, "Enum.InternalCompareTo return code was invalid");
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType"));
}
}
#endregion