https://bugzilla.novell.com/show_bug.cgi?id=328036

           Summary: Casting bug with generic collections
           Product: Mono: Class Libraries
           Version: 1.2
          Platform: PC
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
         QAContact: [EMAIL PROTECTED]
          Found By: Development


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.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to