|
|
>> Enums. Urgh. An enumeration is supposed to be a type that can only take
>> on the specified set of values. Except that in C#, an enumeration can
>> take on /any/ integer value. It's just that some of these values also
>> have friendly names. *sigh*
>
> Erm... did you actually /try/ this??
Quoting Microsoft's C# language specification:
"Each enum type has a corresponding integral type called the
underlying type of the enum type. [...] The set of values that an enum
type can take on is not limited by its enum members. In particular, any
value of the underlying type of an enum can be cast to the enum type and
is a distinct valid value of that enum type."
> Trying to assing an int to an enum variable, I get a "Cannot implicitly
> convert [...]" error for any integer value other than 0. (Don't ask me
> why they did allow it for 0 though.)
Perhaps you can't /implicitly/ convert, but try writing an /explicit/
cast. According to the spec, that's supposed to work.
Post a reply to this message
|
|