I would have put this into bugzilla, but it wouldn't let me, so I'm 
reporting it here...

The code below compiles and runs fine with VS 2005 and prints "a".

With Mono 1.2.4, I get a cast exception:

Unhandled Exception: System.InvalidCastException: Cannot cast from 
source type to destination type.
  at System.Collections.Generic.Dictionary 
2+KeyColleciton[System.String,System.String].System.Collections.ICollection.CopyTo
 
(System.Array , Int32 ) [0x00000]

Here is the code:

            System.Collections.Generic.Dictionary<string, string> d = 
new System.Collections.Generic.Dictionary<string, string>();
            d["a"] = "b";
            System.Collections.ICollection keys = d.Keys;
            object[] keyArray = new object[d.Count];
            keys.CopyTo(keyArray, 0);
            System.Console.WriteLine(keyArray[0]);

Cheers,

Michi.
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to