public sealed class Convert
|
A conversion method exists to convert every base type to every other base type. However, the actual conversion operation performed falls into three categories:
An exception will not be thrown if the conversion of a numeric type results in a loss of precision (that is, the loss of some least significant digits). However, an exception will be thrown if the result is larger than can be represented by the particular conversion method's return value type.
For example, when a Double is converted to a Single, 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 Single, an overflow exception is thrown.
A set of methods support converting an array of bytes to and from a String or array of Unicode characters consisting of base 64 digit characters. Data expressed as base 64 digits can be easily conveyed over data channels that can only transmit 7-bit characters.
Many of the methods in this class convert a source type to a target type by invoking the corresponding IConvertible explicit interface implementation method on the source object. If such a method does not exist, an InvalidCastException is thrown.
Some of the methods in this class take a parameter object that implements the IFormatProvider interface. This parameter can supply culture-specific formatting information to assist the conversion process. The base value types ignore this parameter, but any user-defined type that implements IConvertible can honor it.
For more information about the base value types, see the appropriate topic listed in the See Also section.
double dNumber = 23.15;
try {
// Returns 23
int iNumber = System.Convert.ToInt32(dNumber);
}
catch (System.OverflowException) {
System.Console.WriteLine(
"Overflow in double to int conversion.");
}
// Returns True
bool bNumber = System.Convert.ToBoolean(dNumber);
// Returns "23.15"
string strNumber = System.Convert.ToString(dNumber);
try {
// Returns '2'
char chrNumber = System.Convert.ToChar(strNumber[0]);
}
catch (System.ArgumentNullException) {
System.Console.WriteLine("String is null");
}
catch (System.FormatException) {
System.Console.WriteLine("String length is greater than 1.");
}
// System.Console.ReadLine() returns a string and it
// must be converted.
int newInteger = 0;
try {
System.Console.WriteLine("Enter an integer:");
newInteger = System.Convert.ToInt32(
System.Console.ReadLine());
}
catch (System.ArgumentNullException) {
System.Console.WriteLine("String is null.");
}
catch (System.FormatException) {
System.Console.WriteLine("String does not consist of an " +
"optional sign followed by a series of digits.");
}
catch (System.OverflowException) {
System.Console.WriteLine(
"Overflow in string to int conversion.");
}
System.Console.WriteLine("Your integer as a double is {0}",
System.Convert.ToDouble(newInteger));
| DBNull | A constant representing a database column absent of data; that is, database null. |
| ChangeType | Overloaded:ChangeType(object value, Type conversionType) Returns an Object with the specified Type and whose value is equivalent to the specified object. |
| ChangeType | Overloaded:ChangeType(object value, TypeCode typeCode) Returns an Object with the specified TypeCode and whose value is equivalent to the specified object. |
| ChangeType | Overloaded:ChangeType(object value, Type conversionType, IFormatProvider provider) Returns an Object with the specified Type and whose value is equivalent to the specified object. A parameter supplies culture-specific formatting information. |
| ChangeType | Overloaded:ChangeType(object value, TypeCode typeCode, IFormatProvider provider) Returns an Object with the specified TypeCode and whose value is equivalent to the specified object. A parameter supplies culture-specific formatting information. |
| Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
| FromBase64CharArray | Converts the specified subset of an array of Unicode characters consisting of base 64 digits to an equivalent array of 8-bit unsigned integers. Parameters specify the offset and number of elements in the input array. |
| FromBase64String | Converts the specified String representation of a value consisting of base 64 digits to an equivalent array of 8-bit unsigned integers. |
| GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
| GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
| GetTypeCode | Returns the TypeCode for the specified object. |
| IsDBNull | Returns an indication whether the specified object is of type TypeCode.DBNull. |
| ToBase64CharArray | Converts the value of a subset of an 8-bit unsigned integer array to an equivalent subset of a Unicode character array consisting of base 64 digits. Parameters specify the subsets as offsets of the input and output arrays and the number of elements in the input array. |
| ToBase64String | Overloaded:ToBase64String(byte[] inArray) Converts the value of an array of 8-bit unsigned integers to its equivalent String representation consisting of base 64 digits. |
| ToBase64String | Overloaded:ToBase64String(byte[] inArray, int offset, int length) Converts the value of a subset of an array of 8-bit unsigned integers to its equivalent String representation consisting of base 64 digits. Parameters specify the subset as an offset and number of elements in the array. |
| ToBoolean | Overloaded:ToBoolean(bool value) Returns the specified Boolean value; no actual conversion is performed. |
| ToBoolean | Overloaded:ToBoolean(byte value) Converts the value of the specified 8-bit unsigned integer to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(char value) Calling this method always throws InvalidCastException. |
| ToBoolean | Overloaded:ToBoolean(DateTime value) Calling this method always throws InvalidCastException. |
| ToBoolean | Overloaded:ToBoolean(decimal value) Converts the value of the specified Decimal number to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(double value) Converts the value of the specified double-precision floating point number to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(short value) Converts the value of the specified 16-bit signed integer to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(int value) Converts the value of the specified 32-bit signed integer to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(long value) Converts the value of the specified 64-bit signed integer to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(object value) Converts the value of a specified Object to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(sbyte value) Converts the value of the specified 8-bit signed integer to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(float value) Converts the value of the specified single-precision floating point number to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(string value) Converts the specified String representation of a logical value to its Boolean equivalent. |
| ToBoolean | Overloaded:ToBoolean(ushort value) Converts the value of the specified 16-bit unsigned integer to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent Boolean value. |
| ToBoolean | Overloaded:ToBoolean(object value, IFormatProvider provider) Converts the value of the specified Object to an equivalent Boolean value using the specified culture-specific formatting information. |
| ToBoolean | Overloaded:ToBoolean(string value, IFormatProvider provider) Converts the specified String representation of a logical value to its Boolean equivalent using the specified culture-specific formatting information. |
| ToByte | Overloaded:ToByte(bool value) Converts the value of the specified Boolean value to the equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(byte value) Returns the specified 8-bit unsigned integer; no actual conversion is performed. |
| ToByte | Overloaded:ToByte(char value) Converts the value of the specified Unicode character to the equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(DateTime value) Calling this method always throws InvalidCastException. |
| ToByte | Overloaded:ToByte(decimal value) Converts the value of the specified Decimal number to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(double value) Converts the value of the specified double-precision floating point number to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(short value) Converts the value of the specified 16-bit signed integer to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(int value) Converts the value of the specified 32-bit signed integer to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(long value) Converts the value of the specified 64-bit signed integer to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(object value) Converts the value of the specified Object to an 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(sbyte value) Converts the value of the specified 8-bit signed integer to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(float value) Converts the value of the specified single-precision floating point number to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(string value) Converts the specified String representation of a number to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(ushort value) Converts the value of the specified 16-bit unsigned integer to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent 8-bit unsigned integer. |
| ToByte | Overloaded:ToByte(object value, IFormatProvider provider) Converts the value of the specified Object to an 8-bit unsigned integer using the specified culture-specific formatting information. |
| ToByte | Overloaded:ToByte(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent 8-bit signed integer using specified culture-specific formatting information. |
| ToByte | Overloaded:ToByte(string value, int fromBase) Converts the String representation of a number in a specified base to an equivalent 8-bit unsigned integer. |
| ToChar | Overloaded:ToChar(bool value) Calling this method always throws InvalidCastException. |
| ToChar | Overloaded:ToChar(byte value) Converts the value of the specified 8-bit unsigned integer to its equivalent Unicode character. |
| ToChar | Overloaded:ToChar(char value) Returns the specified Unicode character value; no actual conversion is performed. |
| ToChar | Overloaded:ToChar(DateTime value) Calling this method always throws InvalidCastException. |
| ToChar | Overloaded:ToChar(decimal value) Calling this method always throws InvalidCastException. |
| ToChar | Overloaded:ToChar(double value) Calling this method always throws InvalidCastException. |
| ToChar | Overloaded:ToChar(short value) Converts the value of the specified 16-bit signed integer to its equivalent Unicode character. |
| ToChar | Overloaded:ToChar(int value) Converts the value of the specified 32-bit signed integer to its equivalent Unicode character. |
| ToChar | Overloaded:ToChar(long value) Converts the value of the specified 64-bit signed integer to its equivalent Unicode character. |
| ToChar | Overloaded:ToChar(object value) Converts the value of the specified Object to a Unicode character. |
| ToChar | Overloaded:ToChar(sbyte value) Converts the value of the specified 8-bit signed integer to its equivalent Unicode character. |
| ToChar | Overloaded:ToChar(float value) Calling this method always throws InvalidCastException. |
| ToChar | Overloaded:ToChar(string value) Converts the first character of a String to a Unicode character. |
| ToChar | Overloaded:ToChar(ushort value) Converts the value of the specified 16-bit unsigned integer to its equivalent Unicode character. |
| ToChar | Overloaded:ToChar(uint value) Converts the value of the specified 32-bit unsigned integer to its equivalent Unicode character. |
| ToChar | Overloaded:ToChar(ulong value) Converts the value of the specified 64-bit unsigned integer to its equivalent Unicode character. |
| ToChar | Overloaded:ToChar(object value, IFormatProvider provider) Converts the value of the specified Object to its equivalent Unicode character using the specified culture-specific formatting information. |
| ToChar | Overloaded:ToChar(string value, IFormatProvider provider) Converts the first character of a String to a Unicode character using specified culture-specific formatting information. |
| ToDateTime | Overloaded:ToDateTime(bool value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(byte value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(char value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(DateTime value) Returns the specified DateTime; no actual conversion is performed. |
| ToDateTime | Overloaded:ToDateTime(decimal value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(double value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(short value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(int value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(long value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(object value) Converts the value of the specified Object to a DateTime. |
| ToDateTime | Overloaded:ToDateTime(sbyte value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(float value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(string value) Converts the specified String representation of a date and time to an equivalent DateTime. |
| ToDateTime | Overloaded:ToDateTime(ushort value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(uint value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(ulong value) Calling this method always throws InvalidCastException. |
| ToDateTime | Overloaded:ToDateTime(object value, IFormatProvider provider) Converts the value of the specified Object to a DateTime using the specified culture-specific formatting information. |
| ToDateTime | Overloaded:ToDateTime(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent DateTime using the specified culture-specific formatting information. |
| ToDecimal | Overloaded:ToDecimal(bool value) Converts the value of the specified Boolean value to the equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(char value) Calling this method always throws InvalidCastException. |
| ToDecimal | Overloaded:ToDecimal(DateTime value) Calling this method always throws InvalidCastException. |
| ToDecimal | Overloaded:ToDecimal(decimal value) Returns the specified Decimal number; no actual conversion is performed. |
| ToDecimal | Overloaded:ToDecimal(double value) Converts the value of the specified double-precision floating point number to an equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(short value) Converts the value of the specified 16-bit signed integer to an equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(int value) Converts the value of the specified 32-bit signed integer to an equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(long value) Converts the value of the specified 64-bit signed integer to an equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(object value) Converts the value of the specified Object to a Decimal number. |
| ToDecimal | Overloaded:ToDecimal(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(float value) Converts the value of the specified single-precision floating point number to the equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(string value) Converts the specified String representation of a number to an equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent Decimal number. |
| ToDecimal | Overloaded:ToDecimal(object value, IFormatProvider provider) Converts the value of the specified Object to an Decimal number using the specified culture-specific formatting information. |
| ToDecimal | Overloaded:ToDecimal(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent Decimal number using the specified culture-specific formatting information. |
| ToDouble | Overloaded:ToDouble(bool value) Converts the value of the specified Boolean value to the equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(char value) Calling this method always throws InvalidCastException. |
| ToDouble | Overloaded:ToDouble(DateTime value) Calling this method always throws InvalidCastException. |
| ToDouble | Overloaded:ToDouble(decimal value) Converts the value of the specified Decimal number to an equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(double value) Returns the specified double-precision floating point number; no actual conversion is performed. |
| ToDouble | Overloaded:ToDouble(short value) Converts the value of the specified 16-bit signed integer to an equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(int value) Converts the value of the specified 32-bit signed integer to an equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(long value) Converts the value of the specified 64-bit signed integer to an equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(object value) Converts the value of the specified Object to a double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(float value) Converts the value of the specified single-precision floating point number to an equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(string value) Converts the specified String representation of a number to an equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent double-precision floating point number. |
| ToDouble | Overloaded:ToDouble(object value, IFormatProvider provider) Converts the value of the specified Object to an double-precision floating point number using the specified culture-specific formatting information. |
| ToDouble | Overloaded:ToDouble(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent double-precision floating point number using the specified culture-specific formatting information. |
| ToInt16 | Overloaded:ToInt16(bool value) Converts the value of the specified Boolean value to the equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(char value) Converts the value of the specified Unicode character to the equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(DateTime value) Calling this method always throws InvalidCastException. |
| ToInt16 | Overloaded:ToInt16(decimal value) Converts the value of the specified Decimal number to an equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(double value) Converts the value of the specified double-precision floating point number to an equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(short value) Returns the specified 16-bit signed integer; no actual conversion is performed. |
| ToInt16 | Overloaded:ToInt16(int value) Converts the value of the specified 32-bit signed integer to an equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(long value) Converts the value of the specified 64-bit signed integer to an equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(object value) Converts the value of the specified Object to a 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(float value) Converts the value of the specified single-precision floating point number to an equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(string value) Converts the specified String representation of a number to an equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent 16-bit signed integer. |
| ToInt16 | Overloaded:ToInt16(object value, IFormatProvider provider) Converts the value of the specified Object to a 16-bit signed integer using the specified culture-specific formatting information. |
| ToInt16 | Overloaded:ToInt16(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent 16-bit signed integer using specified culture-specific formatting information. |
| ToInt16 | Overloaded:ToInt16(string value, int fromBase) Converts the String representation of a number in a specified base to an equivalent 16-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(bool value) Converts the value of the specified Boolean value to the equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(char value) Converts the value of the specified Unicode character to the equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(DateTime value) Calling this method always throws InvalidCastException. |
| ToInt32 | Overloaded:ToInt32(decimal value) Converts the value of the specified Decimal number to an equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(double value) Converts the value of the specified double-precision floating point number to an equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(short value) Converts the value of the specified 16-bit signed integer to an equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(int value) Returns the specified 32-bit signed integer; no actual conversion is performed. |
| ToInt32 | Overloaded:ToInt32(long value) Converts the value of the specified 64-bit signed integer to an equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(object value) Converts the value of the specified Object to a 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(float value) Converts the value of the specified single-precision floating point number to an equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(string value) Converts the specified String representation of a number to an equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent 32-bit signed integer. |
| ToInt32 | Overloaded:ToInt32(object value, IFormatProvider provider) Converts the value of the specified Object to a 32-bit signed integer using the specified culture-specific formatting information. |
| ToInt32 | Overloaded:ToInt32(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent 32-bit signed integer using specified culture-specific formatting information. |
| ToInt32 | Overloaded:ToInt32(string value, int fromBase) Converts the String representation of a number in a specified base to an equivalent 32-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(bool value) Converts the value of the specified Boolean value to the equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(char value) Converts the value of the specified Unicode character to the equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(DateTime value) Calling this method always throws InvalidCastException. |
| ToInt64 | Overloaded:ToInt64(decimal value) Converts the value of the specified Decimal number to an equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(double value) Converts the value of the specified double-precision floating point number to an equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(short value) Converts the value of the specified 16-bit signed integer to an equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(int value) Converts the value of the specified 32-bit signed integer to an equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(long value) Returns the specified 64-bit signed integer; no actual conversion is performed. |
| ToInt64 | Overloaded:ToInt64(object value) Converts the value of the specified Object to a 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(float value) Converts the value of the specified single-precision floating point number to an equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(string value) Converts the specified String representation of a number to an equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent 64-bit signed integer. |
| ToInt64 | Overloaded:ToInt64(object value, IFormatProvider provider) Converts the value of the specified Object to a 64-bit signed integer using the specified culture-specific formatting information. |
| ToInt64 | Overloaded:ToInt64(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent 64-bit signed integer using the specified culture-specific formatting information. |
| ToInt64 | Overloaded:ToInt64(string value, int fromBase) Converts the String representation of a number in a specified base to an equivalent 64-bit signed integer. |
| ToSByte | Overloaded:ToSByte(bool value) Converts the value of the specified Boolean value to the equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(char value) Converts the value of the specified Unicode character to the equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(DateTime value) Calling this method always throws InvalidCastException. |
| ToSByte | Overloaded:ToSByte(decimal value) Converts the value of the specified Decimal number to an equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(double value) Converts the value of the specified double-precision floating point number to an equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(short value) Converts the value of the specified 16-bit signed integer to the equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(int value) Converts the value of the specified 32-bit signed integer to an equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(long value) Converts the value of the specified 64-bit signed integer to an equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(object value) Converts the value of the specified Object to an 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(sbyte value) Returns the specified 8-bit signed integer; no actual conversion is performed. |
| ToSByte | Overloaded:ToSByte(float value) Converts the value of the specified single-precision floating point number to an equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(string value) Converts the specified String representation of a number to an equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent 8-bit signed integer. |
| ToSByte | Overloaded:ToSByte(object value, IFormatProvider provider) Converts the value of the specified Object to an 8-bit signed integer using the specified culture-specific formatting information. |
| ToSByte | Overloaded:ToSByte(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent 8-bit signed integer using specified culture-specific formatting information. |
| ToSByte | Overloaded:ToSByte(string value, int fromBase) Converts the String representation of a number in a specified base to an equivalent 8-bit signed integer. |
| ToSingle | Overloaded:ToSingle(bool value) Converts the value of the specified Boolean value to the equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(char value) Calling this method always throws InvalidCastException. |
| ToSingle | Overloaded:ToSingle(DateTime value) Calling this method always throws InvalidCastException. |
| ToSingle | Overloaded:ToSingle(decimal value) Converts the value of the specified Decimal number to an equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(double value) Converts the value of the specified double-precision floating point number to an equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(short value) Converts the value of the specified 16-bit signed integer to an equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(int value) Converts the value of the specified 32-bit signed integer to an equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(long value) Converts the value of the specified 64-bit signed integer to an equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(object value) Converts the value of the specified Object to a single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(float value) Returns the specified single-precision floating point number; no actual conversion is performed. |
| ToSingle | Overloaded:ToSingle(string value) Converts the specified String representation of a number to an equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent single-precision floating point number. |
| ToSingle | Overloaded:ToSingle(object value, IFormatProvider provider) Converts the value of the specified Object to an single-precision floating point number using the specified culture-specific formatting information. |
| ToSingle | Overloaded:ToSingle(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent single-precision floating point number using the specified culture-specific formatting information. |
| ToString (inherited from System.Object) |
Overloaded:ToString()See base class member description: System.Object.ToStringDerived from System.Object, the primary base class for all objects. |
| ToString | Overloaded:ToString(bool value) Converts the value of the specified Boolean to its equivalent String representation. |
| ToString | Overloaded:ToString(byte value) Converts the value of the specified 8-bit unsigned integer to its equivalent String representation. |
| ToString | Overloaded:ToString(char value) Converts the value of the specified Unicode character to its equivalent String representation. |
| ToString | Overloaded:ToString(DateTime value) Converts the value of the specified DateTime to its equivalent String representation. |
| ToString | Overloaded:ToString(decimal value) Converts the value of the specified Decimal number to its equivalent String representation. |
| ToString | Overloaded:ToString(double value) Converts the value of the specified double-precision floating point number to its equivalent String representation. |
| ToString | Overloaded:ToString(short value) Converts the value of the specified 16-bit signed integer to its equivalent String representation. |
| ToString | Overloaded:ToString(int value) Converts the value of the specified 32-bit signed integer to its equivalent String representation. |
| ToString | Overloaded:ToString(long value) Converts the value of the specified 64-bit signed integer to its equivalent String representation. |
| ToString | Overloaded:ToString(object value) Converts the value of the specified Object to its String representation. |
| ToString | Overloaded:ToString(sbyte value) Converts the value of the specified 8-bit signed integer to its equivalent String representation. |
| ToString | Overloaded:ToString(float value) Converts the value of the specified single-precision floating point number to its equivalent String representation. |
| ToString | Overloaded:ToString(string value) Returns the specified instance of String; no actual conversion is performed. |
| ToString | Overloaded:ToString(ushort value) Converts the value of the specified 16-bit unsigned integer to its equivalent String representation. |
| ToString | Overloaded:ToString(uint value) Converts the value of the specified 32-bit unsigned integer to its equivalent String representation. |
| ToString | Overloaded:ToString(ulong value) Converts the value of the specified 64-bit unsigned integer to its equivalent String representation. |
| ToString | Overloaded:ToString(bool value, IFormatProvider provider) Converts the value of the specified Boolean to its equivalent String representation. |
| ToString | Overloaded:ToString(byte value, IFormatProvider provider) Converts the value of the specified 8-bit unsigned integer to its equivalent String representation. |
| ToString | Overloaded:ToString(byte value, int toBase) Converts the value of an 8-bit unsigned integer to its equivalent String representation in a specified base. |
| ToString | Overloaded:ToString(char value, IFormatProvider provider) Converts the value of the specified Unicode character to its equivalent String representation. |
| ToString | Overloaded:ToString(DateTime value, IFormatProvider provider) Converts the value of the specified DateTime to its equivalent String representation. |
| ToString | Overloaded:ToString(decimal value, IFormatProvider provider) Converts the value of the specified Decimal number to its equivalent String representation. |
| ToString | Overloaded:ToString(double value, IFormatProvider provider) Converts the value of the specified double-precision floating point number to its equivalent String representation. |
| ToString | Overloaded:ToString(short value, IFormatProvider provider) Converts the value of the specified 16-bit signed integer to its equivalent String representation. |
| ToString | Overloaded:ToString(short value, int toBase) Converts the value of a 16-bit signed integer to its equivalent String representation in a specified base. |
| ToString | Overloaded:ToString(int value, IFormatProvider provider) Converts the value of the specified 32-bit signed integer to its equivalent String representation. |
| ToString | Overloaded:ToString(int value, int toBase) Converts the value of a 32-bit signed integer to its equivalent String representation in a specified base. |
| ToString | Overloaded:ToString(long value, IFormatProvider provider) Converts the value of the specified 64-bit signed integer to its equivalent String representation. |
| ToString | Overloaded:ToString(long value, int toBase) Converts the value of a 64-bit signed integer to its equivalent String representation in a specified base. |
| ToString | Overloaded:ToString(object value, IFormatProvider provider) Converts the value of the specified Object to its equivalent String representation using the specified culture-specific formatting information. |
| ToString | Overloaded:ToString(sbyte value, IFormatProvider provider) Converts the value of the specified 8-bit signed integer to its equivalent String representation. |
| ToString | Overloaded:ToString(float value, IFormatProvider provider) Converts the value of the specified single-precision floating point number to its equivalent String representation. |
| ToString | Overloaded:ToString(string value, IFormatProvider provider) Returns the specified instance of String; no actual conversion is performed. |
| ToString | Overloaded:ToString(ushort value, IFormatProvider provider) Converts the value of the specified 16-bit unsigned integer to its equivalent String representation. |
| ToString | Overloaded:ToString(uint value, IFormatProvider provider) Converts the value of the specified 32-bit unsigned integer to its equivalent String representation. |
| ToString | Overloaded:ToString(ulong value, IFormatProvider provider) Converts the value of the specified 64-bit unsigned integer to its equivalent String representation. |
| ToUInt16 | Overloaded:ToUInt16(bool value) Converts the value of the specified Boolean value to the equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(char value) Converts the value of the specified Unicode character to the equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(DateTime value) Calling this method always throws InvalidCastException. |
| ToUInt16 | Overloaded:ToUInt16(decimal value) Converts the value of the specified Decimal number to an equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(double value) Converts the value of the specified double-precision floating point number to an equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(short value) Converts the value of the specified 16-bit signed integer to the equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(int value) Converts the value of the specified 32-bit signed integer to an equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(long value) Converts the value of the specified 64-bit signed integer to an equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(object value) Converts the value of the specified Object to a 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(float value) Converts the value of the specified single-precision floating point number to an equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(string value) Converts the specified String representation of a number to an equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(ushort value) Returns the specified 16-bit unsigned integer; no actual conversion is performed. |
| ToUInt16 | Overloaded:ToUInt16(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent 16-bit unsigned integer. |
| ToUInt16 | Overloaded:ToUInt16(object value, IFormatProvider provider) Converts the value of the specified Object to a 16-bit unsigned integer using the specified culture-specific formatting information. |
| ToUInt16 | Overloaded:ToUInt16(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent 16-bit unsigned integer using specified culture-specific formatting information. |
| ToUInt16 | Overloaded:ToUInt16(string value, int fromBase) Converts the String representation of a number in a specified base to an equivalent 16-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(bool value) Converts the value of the specified Boolean value to the equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent 32-bit signed integer. |
| ToUInt32 | Overloaded:ToUInt32(char value) Converts the value of the specified Unicode character to the equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(DateTime value) Calling this method always throws InvalidCastException. |
| ToUInt32 | Overloaded:ToUInt32(decimal value) Converts the value of the specified Decimal number to an equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(double value) Converts the value of the specified double-precision floating point number to an equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(short value) Converts the value of the specified 16-bit signed integer to the equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(int value) Converts the value of the specified 32-bit signed integer to an equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(long value) Converts the value of the specified 64-bit signed integer to an equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(object value) Converts the value of the specified Object to a 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(float value) Converts the value of the specified single-precision floating point number to an equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(string value) Converts the specified String representation of a number to an equivalent 32-bit signed integer. |
| ToUInt32 | Overloaded:ToUInt32(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(uint value) Returns the specified 32-bit unsigned integer; no actual conversion is performed. |
| ToUInt32 | Overloaded:ToUInt32(ulong value) Converts the value of the specified 64-bit unsigned integer to an equivalent 32-bit unsigned integer. |
| ToUInt32 | Overloaded:ToUInt32(object value, IFormatProvider provider) Converts the value of the specified Object to a 32-bit unsigned integer using the specified culture-specific formatting information. |
| ToUInt32 | Overloaded:ToUInt32(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent 32-bit unsigned integer using the specified culture-specific formatting information. |
| ToUInt32 | Overloaded:ToUInt32(string value, int fromBase) Converts the String representation of a number in a specified base to an equivalent 32-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(bool value) Converts the value of the specified Boolean value to the equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(byte value) Converts the value of the specified 8-bit unsigned integer to the equivalent 64-bit signed integer. |
| ToUInt64 | Overloaded:ToUInt64(char value) Converts the value of the specified Unicode character to the equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(DateTime value) Calling this method always throws InvalidCastException. |
| ToUInt64 | Overloaded:ToUInt64(decimal value) Converts the value of the specified Decimal number to an equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(double value) Converts the value of the specified double-precision floating point number to an equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(short value) Converts the value of the specified 16-bit signed integer to the equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(int value) Converts the value of the specified 32-bit signed integer to an equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(long value) Converts the value of the specified 64-bit signed integer to an equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(object value) Converts the value of the specified Object to a 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(sbyte value) Converts the value of the specified 8-bit signed integer to the equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(float value) Converts the value of the specified single-precision floating point number to an equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(string value) Converts the specified String representation of a number to an equivalent 64-bit signed integer. |
| ToUInt64 | Overloaded:ToUInt64(ushort value) Converts the value of the specified 16-bit unsigned integer to the equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(uint value) Converts the value of the specified 32-bit unsigned integer to an equivalent 64-bit unsigned integer. |
| ToUInt64 | Overloaded:ToUInt64(ulong value) Returns the specified 64-bit unsigned integer; no actual conversion is performed. |
| ToUInt64 | Overloaded:ToUInt64(object value, IFormatProvider provider) Converts the value of the specified Object to a 64-bit unsigned integer using the specified culture-specific formatting information. |
| ToUInt64 | Overloaded:ToUInt64(string value, IFormatProvider provider) Converts the specified String representation of a number to an equivalent 64-bit unsigned integer using the specified culture-specific formatting information. |
| ToUInt64 | Overloaded:ToUInt64(string value, int fromBase) Converts the String representation of a number in a specified base to an equivalent 64-bit unsigned integer. |
| Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
| MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public static readonly object DBNull;
|
value
conversionType
| Exception Type | Condition |
|---|---|
| InvalidCastException | value does not implement IConvertible. |
value
typeCode
| Exception Type | Condition |
|---|---|
| InvalidCastException | value does not implement IConvertible. |
| ArgumentException | typeCode is invalid. |
public static object ChangeType( |
value
conversionType
provider
-or-
null, if value and conversionType are nulls.
-or-
value, if the Type of value and conversionType are equal.
| Exception Type | Condition |
|---|---|
| InvalidCastException | value does not implement IConvertible and conversionType is not null or equal to the Type of value. |
| ArgumentException | conversionType is invalid. |
public static object ChangeType( |
value
typeCode
provider
-or-
null if value is null and typeCode is TypeCode.Empty.
| Exception Type | Condition |
|---|---|
| InvalidCastException | value does not implement IConvertible. |
| ArgumentException | typeCode is invalid. |
~Convert(); |
inArray
offset
length
| Exception Type | Condition |
|---|---|
| ArgumentNullException | inArray is null. |
| ArgumentOutOfRangeException | offset or length is less than 0. -or- offset plus length indicates a position not within inArray. |
| FormatException | The length of inArray is less than 4. -or- The length of inArray is not an even multiple of 4. |
public void DecodeWithCharArray() {
System.IO.StreamReader inFile;
char[] base64CharArray;
try {
inFile = new System.IO.StreamReader(inputFileName,
System.Text.Encoding.ASCII);
base64CharArray = new char[inFile.BaseStream.Length];
inFile.Read(base64CharArray, 0, (int)inFile.BaseStream.Length);
inFile.Close();
}
catch (System.Exception exp) {
// Error creating stream or reading from it.
System.Console.WriteLine("{0}", exp.Message);
return;
}
// Convert the Base64 UUEncoded input into binary output.
byte[] binaryData;
try {
binaryData =
System.Convert.FromBase64CharArray(base64CharArray,
0,
base64CharArray.Length);
}
catch ( System.ArgumentNullException ) {
System.Console.WriteLine("Base 64 character array is null.");
return;
}
catch ( System.FormatException ) {
System.Console.WriteLine("Base 64 Char Array length is not " +
"4 or is not an even multiple of 4." );
return;
}
// Write out the decoded data.
System.IO.FileStream outFile;
try {
outFile = new System.IO.FileStream(outputFileName,
System.IO.FileMode.Create,
System.IO.FileAccess.Write);
outFile.Write(binaryData, 0, binaryData.Length);
outFile.Close();
}
catch (System.Exception exp) {
// Error creating stream or writing to it.
System.Console.WriteLine("{0}", exp.Message);
}
}
s
| Exception Type | Condition |
|---|---|
| ArgumentNullException | s is null. |
| FormatException | The length of s is less than 4. -or- The length of s is not an even multiple of 4. |
public void DecodeWithString() {
System.IO.StreamReader inFile;
string base64String;
try {
char[] base64CharArray;
inFile = new System.IO.StreamReader(inputFileName,
System.Text.Encoding.ASCII);
base64CharArray = new char[inFile.BaseStream.Length];
inFile.Read(base64CharArray, 0, (int)inFile.BaseStream.Length);
base64String = ne