IConvertible Interface: define specific methods that will enable the type of value or reference value is converted to a common language runtime types have equivalent values.
The common language runtime types include: Boolean, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Decimal, DateTime, Char and String.
These types are inherited IConvertible interface.
Look interface definition:
public interface IConvertible { TypeCode GetTypeCode(); bool ToBoolean(IFormatProvider provider); char ToChar(IFormatProvider provider); sbyte ToSByte(IFormatProvider provider); byte ToByte(IFormatProvider provider); short ToInt16(IFormatProvider provider); ushort ToUInt16(IFormatProvider provider); int ToInt32(IFormatProvider provider); uint ToUInt32(IFormatProvider provider); long ToInt64(IFormatProvider provider); ulong ToUInt64(IFormatProvider provider); float ToSingle(IFormatProvider provider); double ToDouble(IFormatProvider provider); decimal ToDecimal(IFormatProvider provider); DateTime ToDateTime(IFormatProvider provider); string ToString(IFormatProvider provider); object ToType(Type conversionType, IFormatProvider provider); }
When a class can not be converted to a certain type of common language runtime, it should lead to InvalidCastException exception
GetTypeCode interface method returns the class object TypeCode. TypeCode as an enumerated type specifies the type of object.