[Mono-bugs] [Bug 385486] New: unbox.any and explicit cast operator

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Apr 30 23:12:17 EDT 2008


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


           Summary: unbox.any and explicit cast operator
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: generics
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gonzalo.mono at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Compile (gmcs) and run the following test case:
-------------
using System;

class Test {
        static void Main () {
                Decimal dec = new Decimal(1000);
                Console.WriteLine ((int) dec);
                Console.WriteLine (Cast<int>(dec));
        }

        static T Cast<T> (object value) {
                return (T)value;
        }
}
------------

The output is:
1000

Unhandled Exception: System.InvalidCastException: Cannot cast from source type
to destination type.
  at Test.Main () [0x00000]

-------------

Looks like 'unbox.any' does not know about explicit cast operators. Should
'unbox.any' use the op_Explicit(blah)?


-- 
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.


More information about the mono-bugs mailing list