[CLSCompliant(false)] |
If there is no meaningful conversion to a common language runtime type, then a particular interface method implementation throws InvalidCastException. For example, if this interface is implemented on a Boolean type, the implementation of the IConvertible.ToDateTime method throws an exception because there is no meaningful DateTime equivalent to a Boolean type.
The common language runtime typically exposes the IConvertible interface through the Convert class. The common language runtime also uses the IConvertible interface internally, in , to simplify the code used to support conversions in the Convert class and basic common language runtime types.
In addition to the IConvertible interface, the .NET Framework provides classes called type converters for converting user-defined data types to other data types. For more information, see the the conceptual topic at MSDN: Generalized Type Conversion topic.
GetTypeCode | Returns the TypeCode for this instance. |
ToBoolean | Converts the value of this instance to an equivalent Boolean value using the specified culture-specific formatting information. |
ToByte | Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified culture-specific formatting information. |
ToChar | Converts the value of this instance to an equivalent Unicode character using the specified culture-specific formatting information. |
ToDateTime | Converts the value of this instance to an equivalent DateTime using the specified culture-specific formatting information. |
ToDecimal | Converts the value of this instance to an equivalent Decimal number using the specified culture-specific formatting information. |
ToDouble | Converts the value of this instance to an equivalent double-precision floating-point number using the specified culture-specific formatting information. |
ToInt16 | Converts the value of this instance to an equivalent 16-bit signed integer using the specified culture-specific formatting information. |
ToInt32 | Converts the value of this instance to an equivalent 32-bit signed integer using the specified culture-specific formatting information. |
ToInt64 | Converts the value of this instance to an equivalent 64-bit signed integer using the specified culture-specific formatting information. |
ToSByte | Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture-specific formatting information. |
ToSingle | Converts the value of this instance to an equivalent single-precision floating-point number using the specified culture-specific formatting information. |
ToString | Converts the value of this instance to an equivalent String using the specified culture-specific formatting information. |
ToType | Converts the value of this instance to an Object of the specified Type that has an equivalent value, using the specified culture-specific formatting information. |
ToUInt16 | Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified culture-specific formatting information. |
ToUInt32 | Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified culture-specific formatting information. |
ToUInt64 | Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified culture-specific formatting information. |
TypeCode GetTypeCode(); |
bool ToBoolean( |
provider
byte ToByte( |
provider
char ToChar( |
provider
DateTime ToDateTime( |
provider
decimal ToDecimal( |
provider
double ToDouble( |
provider
short ToInt16( |
provider
int ToInt32( |
provider
long ToInt64( |
provider
sbyte ToSByte( |
provider
float ToSingle( |
provider
string ToString( |
provider
object ToType( |
conversionType
provider
ushort ToUInt16( |
provider
uint ToUInt32( |
provider
ulong ToUInt64( |
provider