[Mono-list] BUG: castclass doesn't allow casting enum[] to underlying type[] (and v.v.)

Jeroen Frijters jeroen@sumatra.nl
Mon, 19 Aug 2002 12:41:01 +0200


The following code throws a System.InvalidCastException:

enum MyEnum : int {}

class Bug
{
  public static void Main() 
  {
    int[] a1 = (int[])(object)new MyEnum[1];
    MyEnum[] a2 = (MyEnum[])(object)new MyEnum[1];
  }
}

Partition III section 4.3 (castclass) explicitly allows this conversion.

Regards,
Jeroen