Mono Class Library: System Namespace

System.Convert Class

Performs conversions between base data types. [Edit]

See Also: Convert Members

public static class Convert

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Remarks

The following table shows conversions from source types to destination types. The first column contains the source types. The remaining columns indicate the destination types the source can be converted to. An 'x' indicates the Convert class implements the conversion.

Note: the column headers correspond precisely, in order, to the source types in the first column, but have been abbreviated to fit.

TypeBoolByteCharDTDecDouI16I32I64SBySinStrUI16UI32UI64
Booleanxxxxxxxxxxxxx
Bytexxxxxxxxxxxxxx
Charxxxxxxxxxx
DateTimexx
Decimalxxxxxxxxxxxxx
Doublexxxxxxxxxxxxx
Int16xxxxxxxxxxxxxx
Int32xxxxxxxxxxxxxx
Int64xxxxxxxxxxxxxx
SBytexxxxxxxxxxxxxx
Singlexxxxxxxxxxxxx
Stringxxxxxxxxxxxxxxx
UInt16xxxxxxxxxxxxxx
UInt32xxxxxxxxxxxxxx
UInt64xxxxxxxxxxxxxx

If the conversion of a numeric type results in a loss of precision, no exception is thrown. However, an exception is thrown if the conversion result is a value that is larger than that which can be represented by the destination type. For example, when a double is converted to a float, a loss of precision might occur but no exception is thrown. However, if the magnitude of the double is too large to be represented by a float, a OverflowException is thrown.

[Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0