O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

IConvertible

Synopsis

The IConvertible interface allows conversion of an object to basic data types and allows the conversion methods in the Convert class to use that object. When implementing the IConvertible interface, create your own type-specific methods for each of the supplied conversion methods.

Note that IConvertible allows one-way conversion from a custom type to other data types, but does not allow a conversion from a basic data type to a custom type.

public interface IConvertible {
// Public Instance Methods
   public method TypeCode GetTypeCode();  
   public method bool ToBoolean(IFormatProvider provider);  
   public method byte ToByte(IFormatProvider provider);  
   public method char ToChar(IFormatProvider provider);  
   public method DateTime ToDateTime(
        IFormatProvider provider);  
   public method decimal ToDecimal(IFormatProvider provider);  
   public method double ToDouble(IFormatProvider provider);  
   public method short ToInt16(IFormatProvider provider);  
   public method int ToInt32(IFormatProvider provider);  
   public method long ToInt64(IFormatProvider provider);  
   public method sbyte ToSByte(IFormatProvider provider);  
   public method float ToSingle(IFormatProvider provider);  
   public method string ToString(IFormatProvider provider);  
   public method object ToType(Type conversionType, 
        IFormatProvider provider);  
   public method ushort ToUInt16(IFormatProvider provider);  
   public method uint ToUInt32(IFormatProvider provider);  
   public method ulong ToUInt64(IFormatProvider provider);  
}

Implemented By

Multiple ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required