[Mono-list] GetTypeCode for Enum

Serge serge@wildwestsoftware.com
Mon, 11 Mar 2002 03:06:50 +0200

> I'm not sure how to add the interface to the class without having to
> define all the To*() methods as public at the same time.

The trick is based on the fact that under CLR class that implements
interface must implement all methods of that interface, but not necessary
under the same name.
See .override directive description in Partition II (9.3.2) for details.
C# syntax for this is to explicitly include interface name in declaration
(and without any visibility modifiers):
   bool IConvertible.ToBool(...) {...}
This way method becomes "visible" when instance is casted to interface type.

Another example of this is ICollection.Count property in the Array class.