[Mono-list] C# question

Gonzalo Paniagua Javier gonzalo@ximian.com
11 Jan 2003 01:51:39 +0100


El sáb, 11-01-2003 a las 21:30, Dan Guidara escribió:

> As far as I understand it, all objects in C# are inherited from class
> object. Therefore every single object can be implicited casted to it,
> (its the base class). Now, the enum is downcasted to an object then
> casted as a Icomparable. It stands to reason that something of type
> object can be convert into any of its child types, I am sure that
> strange behavior occurs from this sometimes.  The second piece of code
> is trying to go directly from an Enum to an Icomplarable through an
> implicit cast which isnt doable given the type differences.
  ^^^^^^^^

It's explicit.

But if you do: "ic = (IComparable) (Enum) en;" it works (and it's an
explicit cast).

Also if you print the interfaces of the type (typeof
(MyEnum).GetInterfaces ()), it shows IComparable...

-Gonzalo