[Mono-list] GetTypeCode for Enum

Serge serge@wildwestsoftware.com
Mon, 11 Mar 2002 17:57:19 +0200

> Code such as below does not compile:
> enum TestEnum {eeny, miney, moe};
> //...
> TestEnum e = TestEnum.eeny;
> bool b = ((IConvertible)e).ToBoolean(); // <- compile error

Oh, my fault, this will require two casts. It looks strange, but
   bool b = ((IConvertible)(Enum)e).ToBoolean(null);
This will set b to false is e is equal to TestEnum.eeny or it will be true