System.Convert Class

Assembly: Mscorlib.dll
Namespace: System
Summary
Converts a base data type to another base data type.
C# Syntax:
public sealed class Convert
Remarks
This class returns a type whose value is equivalent to the value of a specified type. The supported base types are Boolean, Char, SByte, Byte, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, Double, Decimal, DateTime and String.

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.

Example
The following sample demonstrates some of the conversion methods in this class.
			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));

    
See also:
System Namespace | Object | SByte | Int16 | Int32 | Int64 | Byte | UInt16 | UInt32 | UInt64 | Single | Double | Decimal | Boolean | Char | String

System.Convert Member List:

Public Fields
DBNull A constant representing a database column absent of data; that is, database null.
Public Methods
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.ToString

Derived 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.
Protected Methods
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:


System.Convert Member Details

Field: DBNull
Summary
A constant representing a database column absent of data; that is, database null.
C# Syntax:
public static readonly object DBNull;
See also:
DBNull

Return to top


Overloaded Method: ChangeType(
   object value,
   Type conversionType
)
Summary
Returns an Object with the specified Type and whose value is equivalent to the specified object.
C# Syntax:
public static object ChangeType(
   object value,
   Type conversionType
);
Parameters:

value

An Object that implements the IConvertible interface.

conversionType

A Type.

Return Value:
An object whose Type is conversionType and whose value is equivalent to value.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
This method uses the current thread's culture for the conversion.

Return to top


Overloaded Method: ChangeType(
   object value,
   TypeCode typeCode
)
Summary
Returns an Object with the specified TypeCode and whose value is equivalent to the specified object.
C# Syntax:
public static object ChangeType(
   object value,
   TypeCode typeCode
);
Parameters:

value

An Object that implements the IConvertible interface.

typeCode

A TypeCode

Return Value:
An object whose underlying TypeCode is typeCode and whose value is equivalent to value.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
ArgumentException typeCode is invalid.

Return to top


Overloaded Method: ChangeType(
   object value,
   Type conversionType,
   IFormatProvider provider
)
Summary
Returns an Object with the specified Type and whose value is equivalent to the specified object. A parameter supplies culture-specific formatting information.
C# Syntax:
public static object ChangeType(
   object value,
   Type conversionType,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

conversionType

A Type.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
An object whose Type is conversionType and whose value is equivalent to value.

-or-

null, if value and conversionType are nulls.

-or-

value, if the Type of value and conversionType are equal.

Exceptions
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.
Remarks
provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

Return to top


Overloaded Method: ChangeType(
   object value,
   TypeCode typeCode,
   IFormatProvider provider
)
Summary
Returns an Object with the specified TypeCode and whose value is equivalent to the specified object. A parameter supplies culture-specific formatting information.
C# Syntax:
public static object ChangeType(
   object value,
   TypeCode typeCode,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

typeCode

A TypeCode.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
An object whose underlying TypeCode is typeCode and whose value is equivalent to value.

-or-

null if value is null and typeCode is TypeCode.Empty.

Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
ArgumentException typeCode is invalid.
Remarks
provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~Convert();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: FromBase64CharArray(
   char[] inArray,
   int offset,
   int length
)
Summary
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.
C# Syntax:
public static byte[] FromBase64CharArray(
   char[] inArray,
   int offset,
   int length
);
Parameters:

inArray

A Unicode character array.

offset

A position within inArray.

length

The number of elements in inArray to convert.

Return Value:
An array of 8-bit unsigned integers equivalent to length elements at position offset in inArray.
Exceptions
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.

Remarks
The subset in inArray is composed of base 64 digits. The base 64 digits in ascending order from zero are the uppercase characters 'A' to 'Z', lowercase characters 'a' to 'z', numerals '0' to '9', and the symbols '+' and '/'. The valueless character, '=', is used for trailing padding.
Example
The following sample demonstrates using the Convert.FromBase64CharArray method.
		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);
			}
		}

    

Return to top


Method: FromBase64String(
   string s
)
Summary
Converts the specified String representation of a value consisting of base 64 digits to an equivalent array of 8-bit unsigned integers.
C# Syntax:
public static byte[] FromBase64String(
   string s
);
Parameters:

s

A String.

Return Value:
An array of 8-bit unsigned integers equivalent to s.
Exceptions
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.

Remarks
s is composed of base 64 digits. The base 64 digits in ascending order from zero are the uppercase characters 'A' to 'Z', lowercase characters 'a' to 'z', numerals '0' to '9', and the symbols '+' and '/'. The valueless character, '=', is used for trailing padding.
Example
The following sample demonstrates using the Convert.FromBase64String method.
		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 = new string(base64CharArray);
			}
			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.FromBase64String(base64String);
			}
			catch (System.ArgumentNullException) {
				System.Console.WriteLine("Base 64 string is null.");
				return;
			}
			catch (System.FormatException) {
				System.Console.WriteLine("Base 64 string 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);
			}
		}

    

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetTypeCode(
   object value
)
Summary
Returns the TypeCode for the specified object.
C# Syntax:
public static TypeCode GetTypeCode(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface.

Return Value:
The TypeCode for value, or TypeCode.Empty if value is null.

Return to top


Method: IsDBNull(
   object value
)
Summary
Returns an indication whether the specified object is of type TypeCode.DBNull.
C# Syntax:
public static bool IsDBNull(
   object value
);
Parameters:

value

An object.

Return Value:
true if value is of type TypeCode.DBNull; otherwise, false.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToBase64CharArray(
   byte[] inArray,
   int offsetIn,
   int length,
   char[] outArray,
   int offsetOut
)
Summary
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.
C# Syntax:
public static int ToBase64CharArray(
   byte[] inArray,
   int offsetIn,
   int length,
   char[] outArray,
   int offsetOut
);
Parameters:

inArray

An input array of 8-bit unsigned integers.

offsetIn

A position within inArray.

length

The number of elements of inArray to convert.

outArray

An output array of Unicode characters.

offsetOut

A position within outArray.

Return Value:
A 32-bit signed integer containing the number of bytes in outArray.
Exceptions
Exception Type Condition
ArgumentNullException inArray is null.
ArgumentOutOfRangeException offsetIn, offsetOut, or length is negative.

-or-

offsetIn plus length is greater than the length of inArray.

-or-

offsetOut plus the number of elements to return is greater than the length of outArray.

Remarks
The subset of length elements of inArray starting at position offsetIn, are taken as a numeric value and converted to a subset of elements in outArray starting at position offsetOut. The return value indicates the number of converted elements in outArray. The subset of outArray consists of base 64 digits.

The base 64 digits in ascending order from zero are the uppercase characters 'A' to 'Z', lowercase characters 'a' to 'z', numerals '0' to '9', and the symbols '+' and '/'. The valueless character, '=', is used for trailing padding.

offset and length are 32-bit signed numbers.offsetIn and offsetOut are zero-based array positions.

Example
The following sample demonstrates the Convert.ToBase64CharArray method.
		public void EncodeWithCharArray() {
			System.IO.FileStream inFile; 	
			byte[]				 binaryData;

			try {
				inFile = new System.IO.FileStream(inputFileName,
											      System.IO.FileMode.Open,
												  System.IO.FileAccess.Read);
				binaryData = new Byte[inFile.Length];
				long bytesRead = inFile.Read(binaryData, 0,
											(int) inFile.Length);
				inFile.Close();
			}
			catch (System.Exception exp) {
				// Error creating stream or reading from it.
				System.Console.WriteLine("{0}", exp.Message);
				return;
			}

			// Convert the binary input into Base64 UUEncoded output.
			// Each 3 byte sequence in the source data becomes a 4 byte
			// sequence in the character array. 
			long arrayLength = (long) ((4.0d/3.0d) * binaryData.Length);
			
			// If array length is not divisible by 4, go up to the next
			// multiple of 4.
			if (arrayLength % 4 != 0) {
				arrayLength += 4 - arrayLength % 4;
			}
			
			char[] base64CharArray = new char[arrayLength];
			try {
				System.Convert.ToBase64CharArray(binaryData, 
												 0,
												 binaryData.Length,
												 base64CharArray,
												 0);
			}
			catch (System.ArgumentNullException) {
				System.Console.WriteLine("Binary data array is null.");
				return;
			}
			catch (System.ArgumentOutOfRangeException) {
				System.Console.WriteLine("Char Array is not large enough.");
				return;
			}

			// Write the UUEncoded version to the output file.
			System.IO.StreamWriter outFile; 
			try {
				outFile = new System.IO.StreamWriter(outputFileName,
												false,
												System.Text.Encoding.ASCII);			 
				outFile.Write(base64CharArray);
				outFile.Close();
			}
			catch (System.Exception exp) {
				// Error creating stream or writing to it.
				System.Console.WriteLine("{0}", exp.Message);
			}
		}

    

Return to top


Overloaded Method: ToBase64String(
   byte[] inArray
)
Summary
Converts the value of an array of 8-bit unsigned integers to its equivalent String representation consisting of base 64 digits.
C# Syntax:
public static string ToBase64String(
   byte[] inArray
);
Parameters:

inArray

An array of 8-bit unsigned integers.

Return Value:
The String representation, in base 64, of the contents of inArray.
Exceptions
Exception Type Condition
ArgumentNullException inArray is null.
Remarks
The elements of inArray are taken as a numeric value and converted to a String representation consisting of base 64 digits.

The base 64 digits in ascending order from zero are the uppercase characters 'A' to 'Z', lowercase characters 'a' to 'z', numerals '0' to '9', and the symbols '+' and '/'. The valueless character, '=', is used for trailing padding.

Example
The following sample demonstrates the Convert.ToBase64String method.
		public void EncodeWithString() {
			System.IO.FileStream inFile; 	
			byte[]				 binaryData;

			try {
				inFile = new System.IO.FileStream(inputFileName,
												  System.IO.FileMode.Open,
												  System.IO.FileAccess.Read);
				binaryData = new Byte[inFile.Length];
				long bytesRead = inFile.Read(binaryData, 0,
											(int)inFile.Length);
				inFile.Close();
			}
			catch (System.Exception exp) {
				// Error creating stream or reading from it.
				System.Console.WriteLine("{0}", exp.Message);
				return;
			}

			// Convert the binary input into Base64 UUEncoded output.
			string base64String;
			try {
				 base64String = 
					System.Convert.ToBase64String(binaryData, 
												  0,
												  binaryData.Length);
			}
			catch (System.ArgumentNullException) {
				System.Console.WriteLine("Binary data array is null.");
				return;
			}

			// Write the UUEncoded version to the output file.
			System.IO.StreamWriter outFile; 
			try {
				outFile = new System.IO.StreamWriter(outputFileName,
											false,
											System.Text.Encoding.ASCII);			 
				outFile.Write(base64String);
				outFile.Close();
			}
			catch (System.Exception exp) {
				// Error creating stream or writing to it.
				System.Console.WriteLine("{0}", exp.Message);
			}
		}

    
See also:
Byte

Return to top


Overloaded Method: ToBase64String(
   byte[] inArray,
   int offset,
   int length
)
Summary
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.
C# Syntax:
public static string ToBase64String(
   byte[] inArray,
   int offset,
   int length
);
Parameters:

inArray

An array of 8-bit unsigned integers.

offset

An offset in inArray.

length

The number of elements of inArray to convert.

Return Value:
The String representation in base 64 of length elements of inArray starting at position offset.
Exceptions
Exception Type Condition
ArgumentNullException inArray is null.
ArgumentOutOfRangeException offset or length is negative.

-or-

offset plus length is greater than the length of inArray.

Remarks
The elements of inArray are taken as a numeric value and converted to a String representation in base 64.

The base 64 digits in ascending order from zero are the uppercase characters 'A' to 'Z', lowercase characters 'a' to 'z', numerals '0' to '9', and the symbols '+' and '/'. The valueless character, '=', is used for trailing padding.

offset and length are 32-bit signed numbers.offset is zero-based.

Return to top


Overloaded Method: ToBoolean(
   bool value
)
Summary
Returns the specified Boolean value; no actual conversion is performed.
C# Syntax:
public static bool ToBoolean(
   bool value
);
Parameters:

value

A Boolean.

Return Value:
Parameter value is returned unchanged.
See also:
Boolean

Return to top


Overloaded Method: ToBoolean(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to an equivalent Boolean value.
C# Syntax:
public static bool ToBoolean(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
true if value is not zero; otherwise, false.
See also:
Byte

Return to top


Overloaded Method: ToBoolean(
   char value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static bool ToBoolean(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Char

Return to top


Overloaded Method: ToBoolean(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static bool ToBoolean(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToBoolean(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent Boolean value.
C# Syntax:
public static bool ToBoolean(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
true if value is not zero; otherwise, false.
See also:
Decimal

Return to top


Overloaded Method: ToBoolean(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent Boolean value.
C# Syntax:
public static bool ToBoolean(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
true if value is not zero; otherwise, false.
See also:
Double

Return to top


Overloaded Method: ToBoolean(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to an equivalent Boolean value.
C# Syntax:
public static bool ToBoolean(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
true if value is not zero; otherwise, false.
See also:
Int16

Return to top


Overloaded Method: ToBoolean(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent Boolean value.
C# Syntax:
public static bool ToBoolean(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
true if value is not zero; otherwise, false.
See also:
Int32

Return to top


Overloaded Method: ToBoolean(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent Boolean value.
C# Syntax:
public static bool ToBoolean(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
true if value is not zero; otherwise, false.
See also:
Int64

Return to top


Overloaded Method: ToBoolean(
   object value
)
Summary
Converts the value of a specified Object to an equivalent Boolean value.
C# Syntax:
public static bool ToBoolean(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
false if value equals null.

-or-

true or false; the result of invoking the IConvertible.ToBoolean method for the underlying type of value.

See also:
Object

Return to top


Overloaded Method: ToBoolean(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to an equivalent Boolean value.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static bool ToBoolean(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
true if value is not zero; otherwise, false.
See also:
SByte

Return to top


Overloaded Method: ToBoolean(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent Boolean value.
C# Syntax:
public static bool ToBoolean(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
true if value is not zero; otherwise, false.
See also:
Single

Return to top


Overloaded Method: ToBoolean(
   string value
)
Summary
Converts the specified String representation of a logical value to its Boolean equivalent.
C# Syntax:
public static bool ToBoolean(
   string value
);
Parameters:

value

A String that contains the value of either Boolean.TrueString or Boolean.FalseString.

Return Value:
true if value equals Boolean.TrueString, or false if value equals Boolean.FalseString.
Exceptions
Exception Type Condition
ArgumentNullException value is a null reference.
FormatException value is not equal to Boolean.TrueString or Boolean.FalseString
See also:
String

Return to top


Overloaded Method: ToBoolean(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to an equivalent Boolean value.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static bool ToBoolean(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
true if value is not zero; otherwise, false.
See also:
UInt16

Return to top


Overloaded Method: ToBoolean(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent Boolean value.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static bool ToBoolean(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
true if value is not zero; otherwise, false.
See also:
UInt32

Return to top


Overloaded Method: ToBoolean(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent Boolean value.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static bool ToBoolean(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
true if value is not zero; otherwise, false.
See also:
UInt64

Return to top


Overloaded Method: ToBoolean(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to an equivalent Boolean value using the specified culture-specific formatting information.
C# Syntax:
public static bool ToBoolean(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface or null.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
false if value equals null.

-or-

true or false; the result of invoking the ToBoolean method for the underlying type of value.

Exceptions
Exception Type Condition
InvalidCastException value does not implement the IConvertible interface.
Remarks
provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

See also:
Object

Return to top


Overloaded Method: ToBoolean(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a logical value to its Boolean equivalent using the specified culture-specific formatting information.
C# Syntax:
public static bool ToBoolean(
   string value,
   IFormatProvider provider
);
Parameters:

value

A string that contains the value of either Boolean.TrueString or Boolean.FalseString.

provider

(Reserved) An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
true if value equals Boolean.TrueString, or false if value equals Boolean.FalseString.
Exceptions
Exception Type Condition
ArgumentNullException value is a null reference.
FormatException value is not equal to Boolean.TrueString or Boolean.FalseString
Remarks
provider is ignored; it does not participate in this operation.
See also:
String

Return to top


Overloaded Method: ToByte(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToByte(
   byte value
)
Summary
Returns the specified 8-bit unsigned integer; no actual conversion is performed.
C# Syntax:
public static byte ToByte(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToByte(
   char value
)
Summary
Converts the value of the specified Unicode character to the equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The 8-bit unsigned integer equivalent to value.
Exceptions
Exception Type Condition
OverflowException value is greater than Byte.MaxValue.

Return to top


Overloaded Method: ToByte(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static byte ToByte(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToByte(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
value rounded to the nearest 8-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Byte.MaxValue or less than Byte.MinValue.

Return to top


Overloaded Method: ToByte(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
value rounded to the nearest 8-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Byte.MaxValue or less than Byte.MinValue.

Return to top


Overloaded Method: ToByte(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to an equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
An 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than Byte.MinValue or greater than Byte.MaxValue.

Return to top


Overloaded Method: ToByte(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
An 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than Byte.MinValue or greater than Byte.MaxValue.

Return to top


Overloaded Method: ToByte(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
An 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than Byte.MinValue or greater than Byte.MaxValue.

Return to top


Overloaded Method: ToByte(
   object value
)
Summary
Converts the value of the specified Object to an 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
An 8-bit unsigned integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToByte method of the underlying type of value.

Return to top


Overloaded Method: ToByte(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to an equivalent 8-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static byte ToByte(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
An 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than Byte.MinValue.

Return to top


Overloaded Method: ToByte(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
value rounded to the nearest 8-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Byte.MaxValue or less than Byte.MinValue.

Return to top


Overloaded Method: ToByte(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
An 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Byte.MinValue or greater than Byte.MaxValue.
See also:
Byte.Parse

Return to top


Overloaded Method: ToByte(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to an equivalent 8-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static byte ToByte(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
An 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Byte.MaxValue.

Return to top


Overloaded Method: ToByte(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent 8-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static byte ToByte(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
An 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Byte.MaxValue.

Return to top


Overloaded Method: ToByte(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent 8-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static byte ToByte(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
An 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Byte.MaxValue.

Return to top


Overloaded Method: ToByte(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to an 8-bit unsigned integer using the specified culture-specific formatting information.
C# Syntax:
public static byte ToByte(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
An 8-bit unsigned integer equivalent to the value of value, or zero if value is null.
Remarks
provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToByte(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent 8-bit signed integer using specified culture-specific formatting information.
C# Syntax:
public static byte ToByte(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
An 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Byte.MinValue or greater than Byte.MaxValue.
Remarks
provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.
See also:
Byte.Parse

Return to top


Overloaded Method: ToByte(
   string value,
   int fromBase
)
Summary
Converts the String representation of a number in a specified base to an equivalent 8-bit unsigned integer.
C# Syntax:
public static byte ToByte(
   string value,
   int fromBase
);
Parameters:

value

A String containing a number.

fromBase

The base of the number in value, which must be 2, 8, 10, or 16.

Return Value:
An 8-bit unsigned integer equivalent to the number in value.
Exceptions
Exception Type Condition
ArgumentException fromBase is not 2, 8, 10, or 16.
OverflowException value is less than Byte.MinValue or greater than Byte.MaxValue.

Return to top


Overloaded Method: ToChar(
   bool value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static char ToChar(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToChar(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to its equivalent Unicode character.
C# Syntax:
public static char ToChar(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The Unicode character equivalent to the value of value.

Return to top


Overloaded Method: ToChar(
   char value
)
Summary
Returns the specified Unicode character value; no actual conversion is performed.
C# Syntax:
public static char ToChar(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToChar(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static char ToChar(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToChar(
   decimal value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static char ToChar(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToChar(
   double value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static char ToChar(
   double value
);
Parameters:

value

A double-precision floating-point number.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToChar(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to its equivalent Unicode character.
C# Syntax:
public static char ToChar(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
The Unicode character equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than Char.MinValue.

Return to top


Overloaded Method: ToChar(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to its equivalent Unicode character.
C# Syntax:
public static char ToChar(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The Unicode character equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than Char.MinValue or greater than Char.MaxValue.

Return to top


Overloaded Method: ToChar(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to its equivalent Unicode character.
C# Syntax:
public static char ToChar(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
The Unicode character equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than Char.MinValue or greater than Char.MaxValue.

Return to top


Overloaded Method: ToChar(
   object value
)
Summary
Converts the value of the specified Object to a Unicode character.
C# Syntax:
public static char ToChar(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface.

Return Value:
The Unicode character equivalent to the value of value.

-or-

Char.MinValue if value equals null.

Exceptions
Exception Type Condition
InvalidCastException value does not implement the IConvertible interface.
Remarks
The return value is the result of invoking the IConvertible.ToChar method of the underlying type of value.

Return to top


Overloaded Method: ToChar(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to its equivalent Unicode character.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static char ToChar(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The Unicode character equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than Char.MinValue.

Return to top


Overloaded Method: ToChar(
   float value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static char ToChar(
   float value
);
Parameters:

value

A single-precision floating-point number.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToChar(
   string value
)
Summary
Converts the first character of a String to a Unicode character.
C# Syntax:
public static char ToChar(
   string value
);
Parameters:

value

A String of length 1 or null.

Return Value:
The Unicode character equivalent to the first and only character in value.
Exceptions
Exception Type Condition
ArgumentNullException value is null.
FormatException The length of value is not 1.
Remarks
value must be null or a String containing a single character.

Return to top


Overloaded Method: ToChar(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to its equivalent Unicode character.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static char ToChar(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The Unicode character equivalent to the value of value.

Return to top


Overloaded Method: ToChar(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to its equivalent Unicode character.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static char ToChar(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
The Unicode character equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Char.MaxValue.

Return to top


Overloaded Method: ToChar(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to its equivalent Unicode character.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static char ToChar(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
The Unicode character equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Char.MaxValue.

Return to top


Overloaded Method: ToChar(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to its equivalent Unicode character using the specified culture-specific formatting information.
C# Syntax:
public static char ToChar(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The Unicode character equivalent to the value of value.

-or-

Char.MinValue if value equals null.

Exceptions
Exception Type Condition
InvalidCastException value does not implement the IConvertible interface.
Remarks
The return value is the result of invoking the IConvertible.ToChar method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToChar(
   string value,
   IFormatProvider provider
)
Summary
Converts the first character of a String to a Unicode character using specified culture-specific formatting information.
C# Syntax:
public static char ToChar(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String of length 1 or null.

provider

(Reserved) An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The Unicode character equivalent to the first and only character in value.
Exceptions
Exception Type Condition
ArgumentNullException value is null.
FormatException The length of value is not 1.
Remarks
value must be null or a String containing a single character.

provider is ignored; it does not participate in this operation.

Return to top


Overloaded Method: ToDateTime(
   bool value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Boolean

Return to top


Overloaded Method: ToDateTime(
   byte value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Byte

Return to top


Overloaded Method: ToDateTime(
   char value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Char

Return to top


Overloaded Method: ToDateTime(
   DateTime value
)
Summary
Returns the specified DateTime; no actual conversion is performed.
C# Syntax:
public static DateTime ToDateTime(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToDateTime(
   decimal value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   decimal value
);
Parameters:

value

A Decimal value.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToDateTime(
   double value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   double value
);
Parameters:

value

A double-precision floating point value.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Double

Return to top


Overloaded Method: ToDateTime(
   short value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Int16

Return to top


Overloaded Method: ToDateTime(
   int value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Int32

Return to top


Overloaded Method: ToDateTime(
   long value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Int64

Return to top


Overloaded Method: ToDateTime(
   object value
)
Summary
Converts the value of the specified Object to a DateTime.
C# Syntax:
public static DateTime ToDateTime(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A DateTime equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToDateTime method of the underlying type of value.

Return to top


Overloaded Method: ToDateTime(
   sbyte value
)
Summary
Calling this method always throws InvalidCastException.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static DateTime ToDateTime(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Byte

Return to top


Overloaded Method: ToDateTime(
   float value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static DateTime ToDateTime(
   float value
);
Parameters:

value

A single-precision floating point value.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Single

Return to top


Overloaded Method: ToDateTime(
   string value
)
Summary
Converts the specified String representation of a date and time to an equivalent DateTime.
C# Syntax:
public static DateTime ToDateTime(
   string value
);
Parameters:

value

A String containing a date and time to convert.

Return Value:
A DateTime equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value is not a properly formatted date and time.
OverflowException value represents a number less than DateTime.MinValue or greater than DateTime.MaxValue.
Remarks
The return value is the result of invoking the DateTime.Parse method on value.

Return to top


Overloaded Method: ToDateTime(
   ushort value
)
Summary
Calling this method always throws InvalidCastException.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static DateTime ToDateTime(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
UInt16

Return to top


Overloaded Method: ToDateTime(
   uint value
)
Summary
Calling this method always throws InvalidCastException.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static DateTime ToDateTime(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
UInt32

Return to top


Overloaded Method: ToDateTime(
   ulong value
)
Summary
Calling this method always throws InvalidCastException.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static DateTime ToDateTime(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
UInt64

Return to top


Overloaded Method: ToDateTime(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to a DateTime using the specified culture-specific formatting information.
C# Syntax:
public static DateTime ToDateTime(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A DateTime equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToDateTime method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a date, provider could supply culture-specific information about the notation used to represent that date.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToDateTime(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent DateTime using the specified culture-specific formatting information.
C# Syntax:
public static DateTime ToDateTime(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A DateTime equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value is not a properly formatted date and time.
OverflowException value represents a number less than DateTime.MinValue or greater than DateTime.MaxValue.
Remarks
The return value is the result of invoking the DateTime.Parse method on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToDecimal(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent Decimal number.
C# Syntax:
public static decimal ToDecimal(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent Decimal number.
C# Syntax:
public static decimal ToDecimal(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The Decimal number equivalent to the value of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   char value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static decimal ToDecimal(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Char

Return to top


Overloaded Method: ToDecimal(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static decimal ToDecimal(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToDecimal(
   decimal value
)
Summary
Returns the specified Decimal number; no actual conversion is performed.
C# Syntax:
public static decimal ToDecimal(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToDecimal(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent Decimal number.
C# Syntax:
public static decimal ToDecimal(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
A Decimal number equivalent to the value of value. The Decimal contains 15 significant digits and is rounded using rounding to nearest. For example, when rounded to two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36.
Exceptions
Exception Type Condition
OverflowException The numeric value of value is greater than Decimal.MaxValue or less than Decimal.MinValue.
See also:
Double

Return to top


Overloaded Method: ToDecimal(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to an equivalent Decimal number.
C# Syntax:
public static decimal ToDecimal(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
A Decimal number equivalent to the value of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent Decimal number.
C# Syntax:
public static decimal ToDecimal(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
A Decimal number equivalent to the value of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent Decimal number.
C# Syntax:
public static decimal ToDecimal(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
A Decimal number equivalent to the value of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   object value
)
Summary
Converts the value of the specified Object to a Decimal number.
C# Syntax:
public static decimal ToDecimal(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A Decimal number equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToDecimal method of the underlying type of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent Decimal number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static decimal ToDecimal(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to the equivalent Decimal number.
C# Syntax:
public static decimal ToDecimal(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
A Decimal number equivalent to the value of value. The Decimal contains 7 significant digits and is rounded using rounding to nearest. For example, when rounded to two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36.
See also:
Single

Return to top


Overloaded Method: ToDecimal(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent Decimal number.
C# Syntax:
public static decimal ToDecimal(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A Decimal number equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine) and an optional decimal point symbol.
OverflowException value represents a number less than Decimal.MinValue or greater than Decimal.MaxValue.
Remarks
The return value is the result of invoking the Decimal.Parse method on value.

Return to top


Overloaded Method: ToDecimal(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent Decimal number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static decimal ToDecimal(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The Decimal number equivalent to the value of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent Decimal number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static decimal ToDecimal(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
A Decimal number equivalent to the value of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent Decimal number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static decimal ToDecimal(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
A Decimal number equivalent to the value of value.
See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to an Decimal number using the specified culture-specific formatting information.
C# Syntax:
public static decimal ToDecimal(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A Decimal number equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToDecimal method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

See also:
Decimal

Return to top


Overloaded Method: ToDecimal(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent Decimal number using the specified culture-specific formatting information.
C# Syntax:
public static decimal ToDecimal(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A Decimal number equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine) and an optional decimal point symbol.
OverflowException value represents a number less than Decimal.MinValue or greater than Decimal.MaxValue.
Remarks
The return value is the result of invoking the Decimal.Parse method on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToDouble(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent double-precision floating point number.
C# Syntax:
public static double ToDouble(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToDouble(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent double-precision floating point number.
C# Syntax:
public static double ToDouble(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The double-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   char value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static double ToDouble(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Char

Return to top


Overloaded Method: ToDouble(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static double ToDouble(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToDouble(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent double-precision floating point number.
C# Syntax:
public static double ToDouble(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
A double-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   double value
)
Summary
Returns the specified double-precision floating point number; no actual conversion is performed.
C# Syntax:
public static double ToDouble(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
Parameter value is returned unchanged.
See also:
Double

Return to top


Overloaded Method: ToDouble(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to an equivalent double-precision floating point number.
C# Syntax:
public static double ToDouble(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
A double-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent double-precision floating point number.
C# Syntax:
public static double ToDouble(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
A double-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent double-precision floating point number.
C# Syntax:
public static double ToDouble(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
A double-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   object value
)
Summary
Converts the value of the specified Object to a double-precision floating point number.
C# Syntax:
public static double ToDouble(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A double-precision floating point number equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToDouble method of the underlying type of value.

Return to top


Overloaded Method: ToDouble(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent double-precision floating point number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static double ToDouble(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent double-precision floating point number.
C# Syntax:
public static double ToDouble(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
A double-precision floating point number equivalent to the value of value.
See also:
Single

Return to top


Overloaded Method: ToDouble(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent double-precision floating point number.
C# Syntax:
public static double ToDouble(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A double-precision floating point number equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Double.MinValue or greater than Double.MaxValue.
Remarks
The return value is the result of invoking the Double.Parse method on value.

Return to top


Overloaded Method: ToDouble(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent double-precision floating point number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static double ToDouble(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The double-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent double-precision floating point number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static double ToDouble(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
A double-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent double-precision floating point number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static double ToDouble(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
A double-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToDouble(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to an double-precision floating point number using the specified culture-specific formatting information.
C# Syntax:
public static double ToDouble(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A double-precision floating point number equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToDouble method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToDouble(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent double-precision floating point number using the specified culture-specific formatting information.
C# Syntax:
public static double ToDouble(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A double-precision floating point number equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Double.MinValue or greater than Double.MaxValue.
Remarks
The return value is the result of invoking the Double.Parse method on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToInt16(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToInt16(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The 16-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt16(
   char value
)
Summary
Converts the value of the specified Unicode character to the equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The 16-bit signed integer equivalent to value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue.

Return to top


Overloaded Method: ToInt16(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static short ToInt16(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToInt16(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
value rounded to the nearest 16-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue or less than Int16.MinValue.

Return to top


Overloaded Method: ToInt16(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
value rounded to the nearest 16-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue or less than Int16.MinValue.
See also:
Double

Return to top


Overloaded Method: ToInt16(
   short value
)
Summary
Returns the specified 16-bit signed integer; no actual conversion is performed.
C# Syntax:
public static short ToInt16(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToInt16(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The 16-bit signed integer equivalent of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue or less than Int16.MinValue.

Return to top


Overloaded Method: ToInt16(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
A 16-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue or less than Int16.MinValue.

Return to top


Overloaded Method: ToInt16(
   object value
)
Summary
Converts the value of the specified Object to a 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A 16-bit signed integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToInt16 method of the underlying type of value.

Return to top


Overloaded Method: ToInt16(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent 16-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static short ToInt16(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt16(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
value rounded to the nearest 16-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue or less than Int16.MinValue.
See also:
Single

Return to top


Overloaded Method: ToInt16(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A 16-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int16.MinValue or greater than Int16.MaxValue.
See also:
Int16.Parse

Return to top


Overloaded Method: ToInt16(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent 16-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static short ToInt16(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The 16-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue.

Return to top


Overloaded Method: ToInt16(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent 16-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static short ToInt16(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
A 16-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue.

Return to top


Overloaded Method: ToInt16(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent 16-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static short ToInt16(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
A 16-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int16.MaxValue.

Return to top


Overloaded Method: ToInt16(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to a 16-bit signed integer using the specified culture-specific formatting information.
C# Syntax:
public static short ToInt16(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 16-bit signed integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToInt16(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent 16-bit signed integer using specified culture-specific formatting information.
C# Syntax:
public static short ToInt16(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 16-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int16.MinValue or greater than Int16.MaxValue.
Remarks
provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.
See also:
Int16.Parse

Return to top


Overloaded Method: ToInt16(
   string value,
   int fromBase
)
Summary
Converts the String representation of a number in a specified base to an equivalent 16-bit signed integer.
C# Syntax:
public static short ToInt16(
   string value,
   int fromBase
);
Parameters:

value

A String containing a number.

fromBase

The base of the number in value, which must be 2, 8, 10, or 16.

Return Value:
A 16-bit signed integer equivalent to the number in value.
Exceptions
Exception Type Condition
ArgumentException fromBase is not 2, 8, 10, or 16.
OverflowException value is less than Int16.MinValue or greater than Int16.MaxValue.

Return to top


Overloaded Method: ToInt32(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToInt32(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The 32-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt32(
   char value
)
Summary
Converts the value of the specified Unicode character to the equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The 32-bit signed integer equivalent to value.

Return to top


Overloaded Method: ToInt32(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static int ToInt32(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToInt32(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
value rounded to the nearest 32-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int32.MaxValue or less than Int32.MinValue.

Return to top


Overloaded Method: ToInt32(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
value rounded to the nearest 32-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int32.MaxValue or less than Int32.MinValue.
See also:
Double

Return to top


Overloaded Method: ToInt32(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to an equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
A 32-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt32(
   int value
)
Summary
Returns the specified 32-bit signed integer; no actual conversion is performed.
C# Syntax:
public static int ToInt32(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToInt32(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
A 32-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int32.MaxValue or less than Int32.MinValue.

Return to top


Overloaded Method: ToInt32(
   object value
)
Summary
Converts the value of the specified Object to a 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A 32-bit signed integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToInt32 method of the underlying type of value.

Return to top


Overloaded Method: ToInt32(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent 32-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static int ToInt32(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt32(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
value rounded to the nearest 32-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int32.MaxValue or less than Int32.MinValue.
See also:
Single

Return to top


Overloaded Method: ToInt32(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A 32-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int32.MinValue or greater than Int32.MaxValue.
Remarks
The return value is the result of invoking the Int32.Parse method on value.

Return to top


Overloaded Method: ToInt32(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent 32-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static int ToInt32(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The 32-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt32(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent 32-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static int ToInt32(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
A 32-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int32.MaxValue.

Return to top


Overloaded Method: ToInt32(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent 32-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static int ToInt32(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
A 32-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int32.MaxValue.

Return to top


Overloaded Method: ToInt32(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to a 32-bit signed integer using the specified culture-specific formatting information.
C# Syntax:
public static int ToInt32(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 32-bit signed integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToInt32 method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToInt32(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent 32-bit signed integer using specified culture-specific formatting information.
C# Syntax:
public static int ToInt32(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 32-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int32.MinValue or greater than Int32.MaxValue.
Remarks
The return value is the result of invoking the Int32.Parse method on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToInt32(
   string value,
   int fromBase
)
Summary
Converts the String representation of a number in a specified base to an equivalent 32-bit signed integer.
C# Syntax:
public static int ToInt32(
   string value,
   int fromBase
);
Parameters:

value

A String containing a number.

fromBase

The base of the number in value, which must be 2, 8, 10, or 16.

Return Value:
A 32-bit signed integer equivalent to the number in value.
Exceptions
Exception Type Condition
ArgumentException fromBase is not 2, 8, 10, or 16.

Return to top


Overloaded Method: ToInt64(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToInt64(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The 64-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt64(
   char value
)
Summary
Converts the value of the specified Unicode character to the equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The 64-bit signed integer equivalent to value.

Return to top


Overloaded Method: ToInt64(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static long ToInt64(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToInt64(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
value rounded to the nearest 64-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int64.MaxValue or less than Int64.MinValue.

Return to top


Overloaded Method: ToInt64(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
value rounded to the nearest 64-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int64.MaxValue or less than Int64.MinValue.
See also:
Double

Return to top


Overloaded Method: ToInt64(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to an equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
A 64-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt64(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   int value
);
Parameters:

value

A 32-signed integer.

Return Value:
The 64-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt64(
   long value
)
Summary
Returns the specified 64-bit signed integer; no actual conversion is performed.
C# Syntax:
public static long ToInt64(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToInt64(
   object value
)
Summary
Converts the value of the specified Object to a 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A 64-bit signed integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToInt64 method of the underlying type of value.

Return to top


Overloaded Method: ToInt64(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent 64-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static long ToInt64(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt64(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
value rounded to the nearest 64-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than Int64.MaxValue or less than Int64.MinValue.
See also:
Single

Return to top


Overloaded Method: ToInt64(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A 64-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int64.MinValue or greater than Int64.MaxValue.
Remarks
The return value is the result of invoking the Int64.Parse method on value.

Return to top


Overloaded Method: ToInt64(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent 64-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static long ToInt64(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The 64-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt64(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent 64-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static long ToInt64(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
A 64-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToInt64(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent 64-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static long ToInt64(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
A 64-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than Int64.MaxValue.

Return to top


Overloaded Method: ToInt64(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to a 64-bit signed integer using the specified culture-specific formatting information.
C# Syntax:
public static long ToInt64(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 64-bit signed integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToInt64 method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToInt64(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent 64-bit signed integer using the specified culture-specific formatting information.
C# Syntax:
public static long ToInt64(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 64-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int64.MinValue or greater than Int64.MaxValue.
Remarks
The return value is the result of invoking the Int64.Parse method on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToInt64(
   string value,
   int fromBase
)
Summary
Converts the String representation of a number in a specified base to an equivalent 64-bit signed integer.
C# Syntax:
public static long ToInt64(
   string value,
   int fromBase
);
Parameters:

value

A String containing a number.

fromBase

The base of the number in value, which must be 2, 8, 10, or 16.

Return Value:
A 64-bit signed integer equivalent to the number in value.
Exceptions
Exception Type Condition
ArgumentException fromBase is not 2, 8, 10, or 16.

Return to top


Overloaded Method: ToSByte(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToSByte(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue.

Return to top


Overloaded Method: ToSByte(
   char value
)
Summary
Converts the value of the specified Unicode character to the equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The 8-bit signed integer equivalent to value.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue.

Return to top


Overloaded Method: ToSByte(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToSByte(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
value rounded to the nearest 8-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue or less than SByte.MinValue.

Return to top


Overloaded Method: ToSByte(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
value rounded to the nearest 8-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue or less than SByte.MinValue.
See also:
Double

Return to top


Overloaded Method: ToSByte(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to the equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue or less than SByte.MinValue.

Return to top


Overloaded Method: ToSByte(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The 8-bit signed integer equivalent of value.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue or less than SByte.MinValue.

Return to top


Overloaded Method: ToSByte(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
An 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue or less than SByte.MinValue.

Return to top


Overloaded Method: ToSByte(
   object value
)
Summary
Converts the value of the specified Object to an 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
An 8-bit signed integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToSByte method of the underlying type of value.

Return to top


Overloaded Method: ToSByte(
   sbyte value
)
Summary
Returns the specified 8-bit signed integer; no actual conversion is performed.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToSByte(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
value rounded to the nearest 8-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue or less than SByte.MinValue.
See also:
Single

Return to top


Overloaded Method: ToSByte(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
An 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than SByte.MinValue or greater than SByte.MaxValue.
See also:
SByte.Parse

Return to top


Overloaded Method: ToSByte(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue.

Return to top


Overloaded Method: ToSByte(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
An 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue or less than SByte.MinValue.

Return to top


Overloaded Method: ToSByte(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
An 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than SByte.MaxValue or less than SByte.MinValue.

Return to top


Overloaded Method: ToSByte(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to an 8-bit signed integer using the specified culture-specific formatting information.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
An 8-bit signed integer equivalent to the value of value, or zero if value is null.
Remarks
provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToSByte(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent 8-bit signed integer using specified culture-specific formatting information.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
An 8-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than SByte.MinValue or greater than SByte.MaxValue.
Remarks
provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.
See also:
SByte.Parse

Return to top


Overloaded Method: ToSByte(
   string value,
   int fromBase
)
Summary
Converts the String representation of a number in a specified base to an equivalent 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte ToSByte(
   string value,
   int fromBase
);
Parameters:

value

A String containing a number.

fromBase

The base of the number in value, which must be 2, 8, 10, or 16.

Return Value:
An 8-bit signed integer equivalent to the number in value.
Exceptions
Exception Type Condition
ArgumentException fromBase is not 2, 8, 10, or 16.
OverflowException value is less than SByte.MinValue or greater than SByte.MaxValue.

Return to top


Overloaded Method: ToSingle(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent single-precision floating point number.
C# Syntax:
public static float ToSingle(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToSingle(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent single-precision floating point number.
C# Syntax:
public static float ToSingle(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The single-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToSingle(
   char value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static float ToSingle(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.
See also:
Char

Return to top


Overloaded Method: ToSingle(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
C# Syntax:
public static float ToSingle(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToSingle(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent single-precision floating point number.
C# Syntax:
public static float ToSingle(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
A single-precision floating point number equivalent to the value of value.

value is rounded using rounding to nearest. For example, when rounded to two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36.

Return to top


Overloaded Method: ToSingle(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent single-precision floating point number.
C# Syntax:
public static float ToSingle(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
A single-precision floating point number equivalent to the value of value.value is rounded using rounding to nearest. For example, when rounded to two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36.
See also:
Double

Return to top


Overloaded Method: ToSingle(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to an equivalent single-precision floating point number.
C# Syntax:
public static float ToSingle(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
A single-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToSingle(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent single-precision floating point number.
C# Syntax:
public static float ToSingle(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
A single-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToSingle(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent single-precision floating point number.
C# Syntax:
public static float ToSingle(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
A single-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToSingle(
   object value
)
Summary
Converts the value of the specified Object to a single-precision floating point number.
C# Syntax:
public static float ToSingle(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A single-precision floating point number equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToSingle method of the underlying type of value.

Return to top


Overloaded Method: ToSingle(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent single-precision floating point number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static float ToSingle(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 8-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToSingle(
   float value
)
Summary
Returns the specified single-precision floating point number; no actual conversion is performed.
C# Syntax:
public static float ToSingle(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
Parameter value is returned unchanged.
See also:
Single

Return to top


Overloaded Method: ToSingle(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent single-precision floating point number.
C# Syntax:
public static float ToSingle(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A single-precision floating point number equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Single.MinValue or greater than Single.MaxValue.
Remarks
The return value is the result of invoking the Single.Parse method on value.

Return to top


Overloaded Method: ToSingle(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent single-precision floating point number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static float ToSingle(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The single-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToSingle(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent single-precision floating point number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static float ToSingle(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
A single-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToSingle(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent single-precision floating point number.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static float ToSingle(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
A single-precision floating point number equivalent to the value of value.

Return to top


Overloaded Method: ToSingle(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to an single-precision floating point number using the specified culture-specific formatting information.
C# Syntax:
public static float ToSingle(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A single-precision floating point number equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToSingle method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToSingle(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent single-precision floating point number using the specified culture-specific formatting information.
C# Syntax:
public static float ToSingle(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A single-precision floating point number equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Single.MinValue or greater than Single.MaxValue.
Remarks
The return value is the result of invoking the Single.Parse method on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: ToString(
   bool value
)
Summary
Converts the value of the specified Boolean to its equivalent String representation.
C# Syntax:
public static string ToString(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Boolean.ToString.

Return to top


Overloaded Method: ToString(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to its equivalent String representation.
C# Syntax:
public static string ToString(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Byte.ToString.

Return to top


Overloaded Method: ToString(
   char value
)
Summary
Converts the value of the specified Unicode character to its equivalent String representation.
C# Syntax:
public static string ToString(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Char.ToString.

Return to top


Overloaded Method: ToString(
   DateTime value
)
Summary
Converts the value of the specified DateTime to its equivalent String representation.
C# Syntax:
public static string ToString(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to DateTime.ToString.

Return to top


Overloaded Method: ToString(
   decimal value
)
Summary
Converts the value of the specified Decimal number to its equivalent String representation.
C# Syntax:
public static string ToString(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Decimal.ToString.

Return to top


Overloaded Method: ToString(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to its equivalent String representation.
C# Syntax:
public static string ToString(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Double.ToString.

Return to top


Overloaded Method: ToString(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to its equivalent String representation.
C# Syntax:
public static string ToString(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Int16.ToString.

Return to top


Overloaded Method: ToString(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to its equivalent String representation.
C# Syntax:
public static string ToString(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Int32.ToString.

Return to top


Overloaded Method: ToString(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to its equivalent String representation.
C# Syntax:
public static string ToString(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Int64.ToString.

Return to top


Overloaded Method: ToString(
   object value
)
Summary
Converts the value of the specified Object to its String representation.
C# Syntax:
public static string ToString(
   object value
);
Parameters:

value

An Object or null.

Return Value:
The String representation of the value of value, or String.Empty if value is null.
Remarks
The return value is the result of invoking the ToString method of the underlying type of value.

Return to top


Overloaded Method: ToString(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to its equivalent String representation.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static string ToString(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to SByte.ToString.

Return to top


Overloaded Method: ToString(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to its equivalent String representation.
C# Syntax:
public static string ToString(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Single.ToString.

Return to top


Overloaded Method: ToString(
   string value
)
Summary
Returns the specified instance of String; no actual conversion is performed.
C# Syntax:
public static string ToString(
   string value
);
Parameters:

value

A String.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToString(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to its equivalent String representation.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static string ToString(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to UInt16.ToString.

Return to top


Overloaded Method: ToString(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to its equivalent String representation.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static string ToString(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to UInt32.ToString.

Return to top


Overloaded Method: ToString(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to its equivalent String representation.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static string ToString(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to UInt64.ToString.

Return to top


Overloaded Method: ToString(
   bool value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Boolean to its equivalent String representation.
C# Syntax:
public static string ToString(
   bool value,
   IFormatProvider provider
);
Parameters:

value

A Boolean value.

provider

(Reserved) An instance of an IFormatProvider interface implementation.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Boolean.ToString.

Return to top


Overloaded Method: ToString(
   byte value,
   IFormatProvider provider
)
Summary
Converts the value of the specified 8-bit unsigned integer to its equivalent String representation.
C# Syntax:
public static string ToString(
   byte value,
   IFormatProvider provider
);
Parameters:

value

An 8-bit unsigned integer.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Byte.ToString.

Return to top


Overloaded Method: ToString(
   byte value,
   int toBase
)
Summary
Converts the value of an 8-bit unsigned integer to its equivalent String representation in a specified base.
C# Syntax:
public static string ToString(
   byte value,
   int toBase
);
Parameters:

value

An 8-bit unsigned integer.

toBase

The base of the return value, which must be 2, 8, 10, or 16.

Return Value:
The String representation of value in base toBase.
Exceptions
Exception Type Condition
ArgumentException toBase is not 2, 8, 10, or 16.

Return to top


Overloaded Method: ToString(
   char value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Unicode character to its equivalent String representation.
C# Syntax:
public static string ToString(
   char value,
   IFormatProvider provider
);
Parameters:

value

A Unicode character.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Char.ToString.

Return to top


Overloaded Method: ToString(
   DateTime value,
   IFormatProvider provider
)
Summary
Converts the value of the specified DateTime to its equivalent String representation.
C# Syntax:
public static string ToString(
   DateTime value,
   IFormatProvider provider
);
Parameters:

value

A DateTime.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to DateTime.ToString.

Return to top


Overloaded Method: ToString(
   decimal value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Decimal number to its equivalent String representation.
C# Syntax:
public static string ToString(
   decimal value,
   IFormatProvider provider
);
Parameters:

value

A Decimal number.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Decimal.ToString.

Return to top


Overloaded Method: ToString(
   double value,
   IFormatProvider provider
)
Summary
Converts the value of the specified double-precision floating point number to its equivalent String representation.
C# Syntax:
public static string ToString(
   double value,
   IFormatProvider provider
);
Parameters:

value

A double-precision floating point number.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.

provider is ignored; it does not participate in this operation.

Remarks
This implementation is identical to Double.ToString.

Return to top


Overloaded Method: ToString(
   short value,
   IFormatProvider provider
)
Summary
Converts the value of the specified 16-bit signed integer to its equivalent String representation.
C# Syntax:
public static string ToString(
   short value,
   IFormatProvider provider
);
Parameters:

value

A 16-bit signed integer.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Int16.ToString.

Return to top


Overloaded Method: ToString(
   short value,
   int toBase
)
Summary
Converts the value of a 16-bit signed integer to its equivalent String representation in a specified base.
C# Syntax:
public static string ToString(
   short value,
   int toBase
);
Parameters:

value

A 16-bit signed integer.

toBase

The base of the return value, which must be 2, 8, 10, or 16.

Return Value:
The String representation of value in base toBase.
Exceptions
Exception Type Condition
ArgumentException toBase is not 2, 8, 10, or 16.

Return to top


Overloaded Method: ToString(
   int value,
   IFormatProvider provider
)
Summary
Converts the value of the specified 32-bit signed integer to its equivalent String representation.
C# Syntax:
public static string ToString(
   int value,
   IFormatProvider provider
);
Parameters:

value

A 32-bit signed integer.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Int32.ToString.

Return to top


Overloaded Method: ToString(
   int value,
   int toBase
)
Summary
Converts the value of a 32-bit signed integer to its equivalent String representation in a specified base.
C# Syntax:
public static string ToString(
   int value,
   int toBase
);
Parameters:

value

A 32-bit signed integer.

toBase

The base of the return value, which must be 2, 8, 10, or 16.

Return Value:
The String representation of value in base toBase.
Exceptions
Exception Type Condition
ArgumentException toBase is not 2, 8, 10, or 16.

Return to top


Overloaded Method: ToString(
   long value,
   IFormatProvider provider
)
Summary
Converts the value of the specified 64-bit signed integer to its equivalent String representation.
C# Syntax:
public static string ToString(
   long value,
   IFormatProvider provider
);
Parameters:

value

A 64-bit signed integer.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Int64.ToString.

Return to top


Overloaded Method: ToString(
   long value,
   int toBase
)
Summary
Converts the value of a 64-bit signed integer to its equivalent String representation in a specified base.
C# Syntax:
public static string ToString(
   long value,
   int toBase
);
Parameters:

value

A 64-bit signed integer.

toBase

The base of the return value, which must be 2, 8, 10, or 16.

Return Value:
The String representation of value in base toBase.
Exceptions
Exception Type Condition
ArgumentException toBase is not 2, 8, 10, or 16.

Return to top


Overloaded Method: ToString(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to its equivalent String representation using the specified culture-specific formatting information.
C# Syntax:
public static string ToString(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object or null.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String representation of the value of value, or String.Empty if value is null.
Remarks
provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

The return value is the result of invoking the IConvertible.ToString method of the underlying type of value if the underlying type implements the IConvertible interface; otherwise, the return value is the result of invoking the ToString method of the underlying type.

Return to top


Overloaded Method: ToString(
   sbyte value,
   IFormatProvider provider
)
Summary
Converts the value of the specified 8-bit signed integer to its equivalent String representation.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static string ToString(
   sbyte value,
   IFormatProvider provider
);
Parameters:

value

An 8-bit signed integer.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to SByte.ToString.

Return to top


Overloaded Method: ToString(
   float value,
   IFormatProvider provider
)
Summary
Converts the value of the specified single-precision floating point number to its equivalent String representation.
C# Syntax:
public static string ToString(
   float value,
   IFormatProvider provider
);
Parameters:

value

A single-precision floating point number.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to Single.ToString.

Return to top


Overloaded Method: ToString(
   string value,
   IFormatProvider provider
)
Summary
Returns the specified instance of String; no actual conversion is performed.
C# Syntax:
public static string ToString(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
Parameter value is returned unchanged.
Remarks
This method ignores the provider parameter.

Return to top


Overloaded Method: ToString(
   ushort value,
   IFormatProvider provider
)
Summary
Converts the value of the specified 16-bit unsigned integer to its equivalent String representation.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static string ToString(
   ushort value,
   IFormatProvider provider
);
Parameters:

value

A 16-bit unsigned integer.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to UInt16.ToString.

Return to top


Overloaded Method: ToString(
   uint value,
   IFormatProvider provider
)
Summary
Converts the value of the specified 32-bit unsigned integer to its equivalent String representation.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static string ToString(
   uint value,
   IFormatProvider provider
);
Parameters:

value

A 32-bit unsigned integer.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to UInt32.ToString.

Return to top


Overloaded Method: ToString(
   ulong value,
   IFormatProvider provider
)
Summary
Converts the value of the specified 64-bit unsigned integer to its equivalent String representation.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static string ToString(
   ulong value,
   IFormatProvider provider
);
Parameters:

value

A 64-bit unsigned integer.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
The String equivalent of the value of value.
Remarks
This implementation is identical to UInt64.ToString.

Return to top


Overloaded Method: ToUInt16(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToUInt16(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The 16-bit unsigned integer equivalent to the value of value.

Return to top


Overloaded Method: ToUInt16(
   char value
)
Summary
Converts the value of the specified Unicode character to the equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The 16-bit unsigned integer equivalent to value.

Return to top


Overloaded Method: ToUInt16(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToUInt16(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
value rounded to the nearest 16-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt16.MaxValue.

Return to top


Overloaded Method: ToUInt16(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
value rounded to the nearest 16-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt16.MaxValue.
See also:
Double

Return to top


Overloaded Method: ToUInt16(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to the equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   short value
);
Parameters:

value

A 16-bit signed integer.

Return Value:
The 16-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt16(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The 16-bit unsigned integer equivalent of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt16.MaxValue.

Return to top


Overloaded Method: ToUInt16(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
A 16-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt16.MaxValue.

Return to top


Overloaded Method: ToUInt16(
   object value
)
Summary
Converts the value of the specified Object to a 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A 16-bit unsigned integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToUInt16 method of the underlying type of value.

Return to top


Overloaded Method: ToUInt16(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 16-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt16(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
value rounded to the nearest 16-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt16.MaxValue.
See also:
Single

Return to top


Overloaded Method: ToUInt16(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A 16-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int16.MinValue or greater than Int16.MaxValue.
Remarks
The return value is the result of invoking UInt16.Parse on value.

Return to top


Overloaded Method: ToUInt16(
   ushort value
)
Summary
Returns the specified 16-bit unsigned integer; no actual conversion is performed.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToUInt16(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
A 16-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than UInt16.MaxValue.

Return to top


Overloaded Method: ToUInt16(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
A 16-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than UInt16.MaxValue.

Return to top


Overloaded Method: ToUInt16(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to a 16-bit unsigned integer using the specified culture-specific formatting information.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 16-bit unsigned integer equivalent to the value of value, or zero if value is null.
Remarks
The return value is the result of invoking the IConvertible.ToUInt16 method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToUInt16(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent 16-bit unsigned integer using specified culture-specific formatting information.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 16-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int16.MinValue or greater than Int16.MaxValue.
Remarks
The return value is the result of invoking UInt16.Parse on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToUInt16(
   string value,
   int fromBase
)
Summary
Converts the String representation of a number in a specified base to an equivalent 16-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort ToUInt16(
   string value,
   int fromBase
);
Parameters:

value

A String containing a number.

fromBase

The base of the number in value, which must be 2, 8, 10, or 16.

Return Value:
A 16-bit unsigned integer equivalent to the number in value.
Exceptions
Exception Type Condition
ArgumentException fromBase is not 2, 8, 10, or 16.
OverflowException value is less than UInt16.MinValue or greater than UInt16.MaxValue.

Return to top


Overloaded Method: ToUInt32(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToUInt32(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent 32-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The 32-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToUInt32(
   char value
)
Summary
Converts the value of the specified Unicode character to the equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The 32-bit unsigned integer equivalent to value.

Return to top


Overloaded Method: ToUInt32(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToUInt32(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
value rounded to the nearest 32-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt32.MaxValue.

Return to top


Overloaded Method: ToUInt32(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
value rounded to the nearest 32-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt32.MaxValue.
See also:
Double

Return to top


Overloaded Method: ToUInt32(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to the equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   short value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The 32-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt32(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The 32-bit unsigned integer equivalent of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt32(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
A 32-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt32.MaxValue.

Return to top


Overloaded Method: ToUInt32(
   object value
)
Summary
Converts the value of the specified Object to a 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A 32-bit unsigned integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToUInt32 method of the underlying type of value.

Return to top


Overloaded Method: ToUInt32(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt32(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
value rounded to the nearest 32-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt32.MaxValue.
See also:
Single

Return to top


Overloaded Method: ToUInt32(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent 32-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A 32-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int32.MinValue or greater than Int32.MaxValue.
Remarks
The return value is the result of invoking the Int32.Parse method on value.

Return to top


Overloaded Method: ToUInt32(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   ushort value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The 32-bit unsigned integer equivalent to the value of value.

Return to top


Overloaded Method: ToUInt32(
   uint value
)
Summary
Returns the specified 32-bit unsigned integer; no actual conversion is performed.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToUInt32(
   ulong value
)
Summary
Converts the value of the specified 64-bit unsigned integer to an equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
A 32-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is greater than UInt32.MaxValue.

Return to top


Overloaded Method: ToUInt32(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to a 32-bit unsigned integer using the specified culture-specific formatting information.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 32-bit unsigned integer equivalent to the value of value, or zero if value is null.
Remarks
The return value is the result of invoking the IConvertible.ToUInt32 method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToUInt32(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent 32-bit unsigned integer using the specified culture-specific formatting information.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 32-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int32.MinValue or greater than Int32.MaxValue.
Remarks
The return value is the result of invoking UInt32.Parse on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToUInt32(
   string value,
   int fromBase
)
Summary
Converts the String representation of a number in a specified base to an equivalent 32-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint ToUInt32(
   string value,
   int fromBase
);
Parameters:

value

A String containing a number.

fromBase

The base of the number in value, which must be 2, 8, 10, or 16.

Return Value:
A 32-bit unsigned integer equivalent to the number in value.
Exceptions
Exception Type Condition
ArgumentException fromBase is not 2, 8, 10, or 16.

Return to top


Overloaded Method: ToUInt64(
   bool value
)
Summary
Converts the value of the specified Boolean value to the equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   bool value
);
Parameters:

value

A Boolean value.

Return Value:
The number 1 if value is true; otherwise, 0.

Return to top


Overloaded Method: ToUInt64(
   byte value
)
Summary
Converts the value of the specified 8-bit unsigned integer to the equivalent 64-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   byte value
);
Parameters:

value

An 8-bit unsigned integer.

Return Value:
The 64-bit signed integer equivalent to the value of value.

Return to top


Overloaded Method: ToUInt64(
   char value
)
Summary
Converts the value of the specified Unicode character to the equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   char value
);
Parameters:

value

A Unicode character.

Return Value:
The 64-bit unsigned integer equivalent to value.

Return to top


Overloaded Method: ToUInt64(
   DateTime value
)
Summary
Calling this method always throws InvalidCastException.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   DateTime value
);
Parameters:

value

A DateTime.

Return Value:
This conversion is not supported. No value is returned.
Exceptions
Exception Type Condition
InvalidCastException This conversion is not supported.
Remarks
This method is reserved for future use.

Return to top


Overloaded Method: ToUInt64(
   decimal value
)
Summary
Converts the value of the specified Decimal number to an equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   decimal value
);
Parameters:

value

A Decimal number.

Return Value:
value rounded to the nearest 64-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt64.MaxValue.

Return to top


Overloaded Method: ToUInt64(
   double value
)
Summary
Converts the value of the specified double-precision floating point number to an equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   double value
);
Parameters:

value

A double-precision floating point number.

Return Value:
value rounded to the nearest 64-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt64.MaxValue.
See also:
Double

Return to top


Overloaded Method: ToUInt64(
   short value
)
Summary
Converts the value of the specified 16-bit signed integer to the equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   short value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
The 64-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt64(
   int value
)
Summary
Converts the value of the specified 32-bit signed integer to an equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   int value
);
Parameters:

value

A 32-bit signed integer.

Return Value:
The 64-bit unsigned integer equivalent of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt64(
   long value
)
Summary
Converts the value of the specified 64-bit signed integer to an equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   long value
);
Parameters:

value

A 64-bit signed integer.

Return Value:
A 64-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt64(
   object value
)
Summary
Converts the value of the specified Object to a 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   object value
);
Parameters:

value

An Object that implements the IConvertible interface or null.

Return Value:
A 64-bit unsigned integer equivalent to the value of value, or zero if value is null.
Exceptions
Exception Type Condition
InvalidCastException value does not implement IConvertible.
Remarks
The return value is the result of invoking the IConvertible.ToUInt64 method of the underlying type of value.

Return to top


Overloaded Method: ToUInt64(
   sbyte value
)
Summary
Converts the value of the specified 8-bit signed integer to the equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   sbyte value
);
Parameters:

value

An 8-bit signed integer.

Return Value:
The 8-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
OverflowException value is less than zero.

Return to top


Overloaded Method: ToUInt64(
   float value
)
Summary
Converts the value of the specified single-precision floating point number to an equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   float value
);
Parameters:

value

A single-precision floating point number.

Return Value:
value rounded to the nearest 64-bit unsigned integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.
Exceptions
Exception Type Condition
OverflowException value is less than zero or greater than UInt64.MaxValue.
See also:
Single

Return to top


Overloaded Method: ToUInt64(
   string value
)
Summary
Converts the specified String representation of a number to an equivalent 64-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   string value
);
Parameters:

value

A String containing a number to convert.

Return Value:
A 64-bit signed integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int64.MinValue or greater than Int64.MaxValue.
Remarks
The return value is the result of invoking the Int64.Parse method on value.

Return to top


Overloaded Method: ToUInt64(
   ushort value
)
Summary
Converts the value of the specified 16-bit unsigned integer to the equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   ushort value
);
Parameters:

value

A 16-bit unsigned integer.

Return Value:
The 64-bit unsigned integer equivalent to the value of value.

Return to top


Overloaded Method: ToUInt64(
   uint value
)
Summary
Converts the value of the specified 32-bit unsigned integer to an equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   uint value
);
Parameters:

value

A 32-bit unsigned integer.

Return Value:
The 64-bit unsigned integer equivalent of value.

Return to top


Overloaded Method: ToUInt64(
   ulong value
)
Summary
Returns the specified 64-bit unsigned integer; no actual conversion is performed.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   ulong value
);
Parameters:

value

A 64-bit unsigned integer.

Return Value:
Parameter value is returned unchanged.

Return to top


Overloaded Method: ToUInt64(
   object value,
   IFormatProvider provider
)
Summary
Converts the value of the specified Object to a 64-bit unsigned integer using the specified culture-specific formatting information.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   object value,
   IFormatProvider provider
);
Parameters:

value

An Object that implements the IConvertible interface.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 64-bit unsigned integer equivalent to the value of value, or zero if value is null.
Remarks
The return value is the result of invoking the IConvertible.ToUInt64 method of the underlying type of value.

provider enables the user to specify culture-specific conversion information about the contents of value. For example, if value is a String that represents a number, provider could supply culture-specific information about the notation used to represent that number.

The base types ignore provider; however, it is honored if value is a user-defined type that implements the IConvertible interface.

Return to top


Overloaded Method: ToUInt64(
   string value,
   IFormatProvider provider
)
Summary
Converts the specified String representation of a number to an equivalent 64-bit unsigned integer using the specified culture-specific formatting information.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   string value,
   IFormatProvider provider
);
Parameters:

value

A String containing a number to convert.

provider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value:
A 64-bit unsigned integer equivalent to the value of value.
Exceptions
Exception Type Condition
ArgumentException value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException value represents a number less than Int64.MinValue or greater than Int64.MaxValue.
Remarks
The return value is the result of invoking UInt64.Parse on value.

provider is an IFormatProvider instance that obtains a NumberFormatInfo object. The NumberFormatInfo object provides culture-specific information about the format of value. If provider is null, the NumberFormatInfo for the current culture is used.

Return to top


Overloaded Method: ToUInt64(
   string value,
   int fromBase
)
Summary
Converts the String representation of a number in a specified base to an equivalent 64-bit unsigned integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong ToUInt64(
   string value,
   int fromBase
);
Parameters:

value

A String containing a number.

fromBase

The base of the number in value, which must be 2, 8, 10, or 16.

Return Value:
A 64-bit unsigned integer equivalent to the number in value.
Exceptions
Exception Type Condition
ArgumentException fromBase is not 2, 8, 10, or 16.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.