public sealed class Convert
Object
Convert
mscorlib
BCL
Performs conversions between base data types.
The following table shows conversions from source types to destination types. The first column contains the source types. The remaining columns indicate the destination types the source may be converted to. An 'x' indicates the Convert class implements the conversion. [Note: the column headers correspond precisely, in order, to the source types in the first column, but have been abbreviated to fit.]
If the conversion of a numeric type results in a loss of precision, no exception is thrown. However, an exception is thrown if the conversion result is a value that is larger than that which can be represented by the destination type. For example, when a Double is converted to a Single, a loss of precision may occur but no exception is thrown. However, if the magnitude of the Double is too large to be represented by a Single, a OverflowException is thrown.
Type Bool Boolean x Byte x Char DateTime Decimal x Double x Int16 x Int32 x Int64 x SByte x Single x String x UInt16 x UInt32 x UInt64 x
System Namespace
Convert Methods
Convert.ToBoolean(bool) Method
Convert.ToBoolean(sbyte) Method
Convert.ToBoolean(byte) Method
Convert.ToBoolean(short) Method
Convert.ToBoolean(ushort) Method
Convert.ToBoolean(int) Method
Convert.ToBoolean(uint) Method
Convert.ToBoolean(long) Method
Convert.ToBoolean(ulong) Method
Convert.ToBoolean(System.String) Method
Convert.ToBoolean(float) Method
Convert.ToBoolean(double) Method
Convert.ToBoolean(System.Decimal) Method
Convert.ToByte(bool) Method
Convert.ToByte(byte) Method
Convert.ToByte(char) Method
Convert.ToByte(sbyte) Method
Convert.ToByte(short) Method
Convert.ToByte(ushort) Method
Convert.ToByte(int) Method
Convert.ToByte(uint) Method
Convert.ToByte(long) Method
Convert.ToByte(ulong) Method
Convert.ToByte(float) Method
Convert.ToByte(double) Method
Convert.ToByte(System.Decimal) Method
Convert.ToByte(System.String) Method
Convert.ToByte(System.String, System.IFormatProvider) Method
Convert.ToChar(char) Method
Convert.ToChar(sbyte) Method
Convert.ToChar(byte) Method
Convert.ToChar(short) Method
Convert.ToChar(ushort) Method
Convert.ToChar(int) Method
Convert.ToChar(uint) Method
Convert.ToChar(long) Method
Convert.ToChar(ulong) Method
Convert.ToChar(System.String) Method
Convert.ToDateTime(System.DateTime) Method
Convert.ToDateTime(System.String) Method
Convert.ToDateTime(System.String, System.IFormatProvider) Method
Convert.ToDecimal(sbyte) Method
Convert.ToDecimal(byte) Method
Convert.ToDecimal(short) Method
Convert.ToDecimal(ushort) Method
Convert.ToDecimal(int) Method
Convert.ToDecimal(uint) Method
Convert.ToDecimal(long) Method
Convert.ToDecimal(ulong) Method
Convert.ToDecimal(float) Method
Convert.ToDecimal(double) Method
Convert.ToDecimal(System.String) Method
Convert.ToDecimal(System.String, System.IFormatProvider) Method
Convert.ToDecimal(System.Decimal) Method
Convert.ToDecimal(bool) Method
Convert.ToDouble(sbyte) Method
Convert.ToDouble(byte) Method
Convert.ToDouble(short) Method
Convert.ToDouble(ushort) Method
Convert.ToDouble(int) Method
Convert.ToDouble(uint) Method
Convert.ToDouble(long) Method
Convert.ToDouble(ulong) Method
Convert.ToDouble(float) Method
Convert.ToDouble(double) Method
Convert.ToDouble(System.Decimal) Method
Convert.ToDouble(System.String) Method
Convert.ToDouble(System.String, System.IFormatProvider) Method
Convert.ToDouble(bool) Method
Convert.ToInt16(bool) Method
Convert.ToInt16(char) Method
Convert.ToInt16(sbyte) Method
Convert.ToInt16(byte) Method
Convert.ToInt16(ushort) Method
Convert.ToInt16(int) Method
Convert.ToInt16(uint) Method
Convert.ToInt16(short) Method
Convert.ToInt16(long) Method
Convert.ToInt16(ulong) Method
Convert.ToInt16(float) Method
Convert.ToInt16(double) Method
Convert.ToInt16(System.Decimal) Method
Convert.ToInt16(System.String) Method
Convert.ToInt16(System.String, System.IFormatProvider) Method
Convert.ToInt32(bool) Method
Convert.ToInt32(char) Method
Convert.ToInt32(sbyte) Method
Convert.ToInt32(byte) Method
Convert.ToInt32(short) Method
Convert.ToInt32(ushort) Method
Convert.ToInt32(uint) Method
Convert.ToInt32(int) Method
Convert.ToInt32(long) Method
Convert.ToInt32(ulong) Method
Convert.ToInt32(float) Method
Convert.ToInt32(double) Method
Convert.ToInt32(System.Decimal) Method
Convert.ToInt32(System.String) Method
Convert.ToInt32(System.String, System.IFormatProvider) Method
Convert.ToInt64(bool) Method
Convert.ToInt64(char) Method
Convert.ToInt64(sbyte) Method
Convert.ToInt64(byte) Method
Convert.ToInt64(short) Method
Convert.ToInt64(ushort) Method
Convert.ToInt64(int) Method
Convert.ToInt64(uint) Method
Convert.ToInt64(ulong) Method
Convert.ToInt64(long) Method
Convert.ToInt64(float) Method
Convert.ToInt64(double) Method
Convert.ToInt64(System.Decimal) Method
Convert.ToInt64(System.String) Method
Convert.ToInt64(System.String, System.IFormatProvider) Method
Convert.ToSByte(bool) Method
Convert.ToSByte(sbyte) Method
Convert.ToSByte(char) Method
Convert.ToSByte(byte) Method
Convert.ToSByte(short) Method
Convert.ToSByte(ushort) Method
Convert.ToSByte(int) Method
Convert.ToSByte(uint) Method
Convert.ToSByte(long) Method
Convert.ToSByte(ulong) Method
Convert.ToSByte(float) Method
Convert.ToSByte(double) Method
Convert.ToSByte(System.Decimal) Method
Convert.ToSByte(System.String) Method
Convert.ToSByte(System.String, System.IFormatProvider) Method
Convert.ToSingle(sbyte) Method
Convert.ToSingle(byte) Method
Convert.ToSingle(short) Method
Convert.ToSingle(ushort) Method
Convert.ToSingle(int) Method
Convert.ToSingle(uint) Method
Convert.ToSingle(long) Method
Convert.ToSingle(ulong) Method
Convert.ToSingle(float) Method
Convert.ToSingle(double) Method
Convert.ToSingle(System.Decimal) Method
Convert.ToSingle(System.String) Method
Convert.ToSingle(System.String, System.IFormatProvider) Method
Convert.ToSingle(bool) Method
Convert.ToString(bool) Method
Convert.ToString(char) Method
Convert.ToString(sbyte) Method
Convert.ToString(sbyte, System.IFormatProvider) Method
Convert.ToString(byte) Method
Convert.ToString(byte, System.IFormatProvider) Method
Convert.ToString(short) Method
Convert.ToString(short, System.IFormatProvider) Method
Convert.ToString(ushort) Method
Convert.ToString(ushort, System.IFormatProvider) Method
Convert.ToString(int) Method
Convert.ToString(int, System.IFormatProvider) Method
Convert.ToString(uint) Method
Convert.ToString(uint, System.IFormatProvider) Method
Convert.ToString(long) Method
Convert.ToString(long, System.IFormatProvider) Method
Convert.ToString(ulong) Method
Convert.ToString(ulong, System.IFormatProvider) Method
Convert.ToString(float) Method
Convert.ToString(float, System.IFormatProvider) Method
Convert.ToString(double) Method
Convert.ToString(double, System.IFormatProvider) Method
Convert.ToString(System.Decimal) Method
Convert.ToString(System.Decimal, System.IFormatProvider) Method
Convert.ToString(System.DateTime) Method
Convert.ToString(System.DateTime, System.IFormatProvider) Method
Convert.ToString(System.String) Method
Convert.ToUInt16(bool) Method
Convert.ToUInt16(char) Method
Convert.ToUInt16(sbyte) Method
Convert.ToUInt16(byte) Method
Convert.ToUInt16(short) Method
Convert.ToUInt16(int) Method
Convert.ToUInt16(ushort) Method
Convert.ToUInt16(uint) Method
Convert.ToUInt16(long) Method
Convert.ToUInt16(ulong) Method
Convert.ToUInt16(float) Method
Convert.ToUInt16(double) Method
Convert.ToUInt16(System.Decimal) Method
Convert.ToUInt16(System.String) Method
Convert.ToUInt16(System.String, System.IFormatProvider) Method
Convert.ToUInt32(bool) Method
Convert.ToUInt32(char) Method
Convert.ToUInt32(sbyte) Method
Convert.ToUInt32(byte) Method
Convert.ToUInt32(short) Method
Convert.ToUInt32(ushort) Method
Convert.ToUInt32(int) Method
Convert.ToUInt32(uint) Method
Convert.ToUInt32(long) Method
Convert.ToUInt32(ulong) Method
Convert.ToUInt32(float) Method
Convert.ToUInt32(double) Method
Convert.ToUInt32(System.Decimal) Method
Convert.ToUInt32(System.String) Method
Convert.ToUInt32(System.String, System.IFormatProvider) Method
Convert.ToUInt64(bool) Method
Convert.ToUInt64(char) Method
Convert.ToUInt64(sbyte) Method
Convert.ToUInt64(byte) Method
Convert.ToUInt64(short) Method
Convert.ToUInt64(ushort) Method
Convert.ToUInt64(int) Method
Convert.ToUInt64(uint) Method
Convert.ToUInt64(long) Method
Convert.ToUInt64(ulong) Method
Convert.ToUInt64(float) Method
Convert.ToUInt64(double) Method
Convert.ToUInt64(System.Decimal) Method
Convert.ToUInt64(System.String) Method
Convert.ToUInt64(System.String, System.IFormatProvider) Method
public static bool ToBoolean(bool value);
Converts a Boolean to a Boolean .
- value
- The Boolean value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
System.Convert Class, System Namespace
public static bool ToBoolean(sbyte value);
Converts a SByte to a Boolean .
- value
- The 8-bit signed integer value to be converted.
true
if value is non-zero;false
if value is zero.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToBoolean(System.Object)(Int16).
The following example demonstrates converting SByte values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { sbyte sbyte0 = (sbyte) 0; sbyte sbyte1 = (sbyte) 1; sbyte sbyte2 = (sbyte) -2; bool bool0 = Convert.ToBoolean(sbyte0); bool bool1 = Convert.ToBoolean(sbyte1); bool bool2 = Convert.ToBoolean(sbyte2); Console.WriteLine("(sbyte) {0} as bool = {1}",sbyte0,bool0); Console.WriteLine("(sbyte) {0} as bool = {1}",sbyte1,bool1); Console.WriteLine("(sbyte) {0} as bool = {1}",sbyte2,bool2); } }The output is
(sbyte) 0 as bool = False
(sbyte) 1 as bool = True
(sbyte) -2 as bool = True
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static bool ToBoolean(byte value);
Converts a Byte to a Boolean .
- value
- The Byte value to be converted.
true
if value is non-zero;false
if value is zero.
The following example demonstrates converting Byte values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { byte byte0 = (byte) 0; byte byte1 = (Byte) 1; bool bool0 = Convert.ToBoolean(byte0); bool bool1 = Convert.ToBoolean(byte1); Console.WriteLine("(byte) {0} as bool = {1}",byte0,bool0); Console.WriteLine("(byte) {0} as bool = {1}",byte1,bool1); } }The output is
(byte) 0 as bool = False
(byte) 1 as bool = True
System.Convert Class, System Namespace
public static bool ToBoolean(short value);
Converts a Int16 to a Boolean .
- value
- The 16-bit signed integer value to be converted.
true
if value is non-zero;false
if value is zero.
The following example demonstrates converting Byte values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { short short0 = 0; short short1 = 1; short short2 = -2; bool bool0 = Convert.ToBoolean(short0); bool bool1 = Convert.ToBoolean(short1); bool bool2 = Convert.ToBoolean(short2); Console.WriteLine("(short) {0} as bool = {1}",short0,bool0); Console.WriteLine("(short) {0} as bool = {1}",short1,bool1); Console.WriteLine("(short) {0} as bool = {1}",short2,bool2); } }The output is
(short) 0 as bool = False
(short) 1 as bool = True
(short) -2 as bool = True
System.Convert Class, System Namespace
public static bool ToBoolean(ushort value);
Converts a UInt16 to a Boolean .
- value
- The 16-bit unsigned integer value to be converted.
true
if value is non-zero;false
if value is zero.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToBoolean(System.Object)(Int32).
The following example demonstrates converting Int16 values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { ushort ushort0 = 0; ushort ushort1 = 1; bool bool0 = Convert.ToBoolean(ushort0); bool bool1 = Convert.ToBoolean(ushort1); Console.WriteLine("(ushort) {0} as bool = {1}",ushort0,bool0); Console.WriteLine("(ushort) {0} as bool = {1}",ushort1,bool1); } }The output is
(ushort) 0 as bool = False
(ushort) 1 as bool = True
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static bool ToBoolean(int value);
Converts a Int32 to a Boolean .
- value
- The 32-bit signed integer value to be converted.
true
if value is non-zero;false
if value is zero.
The following example demonstrates converting Int32 values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { int int0 = 0; int int1 = 1; int int2 = -2; bool bool0 = Convert.ToBoolean(int0); bool bool1 = Convert.ToBoolean(int1); bool bool2 = Convert.ToBoolean(int2); Console.WriteLine("(int) {0} as bool = {1}",int0,bool0); Console.WriteLine("(int) {0} as bool = {1}",int1,bool1); Console.WriteLine("(int) {0} as bool = {1}",int2,bool2); } }The output is
(int) 0 as bool = False
(int) 1 as bool = True
(int) -2 as bool = True
System.Convert Class, System Namespace
public static bool ToBoolean(uint value);
Converts a UInt32 to a Boolean .
- value
- The 32-bit unsigned integer value to be converted.
true
if value is non-zero;false
if value is zero.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToBoolean(System.Object)(Int64).
The following example demonstrates converting UInt32 values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { uint uint0 = 0; uint uint1 = 1; bool bool0 = Convert.ToBoolean(uint0); bool bool1 = Convert.ToBoolean(uint1); Console.WriteLine("(uint) {0} as bool = {1}",uint0,bool0); Console.WriteLine("(uint) {0} as bool = {1}",uint1,bool1); } }The output is
(uint) 0 as bool = False
(uint) 1 as bool = True
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static bool ToBoolean(long value);
Converts a Int64 to a Boolean .
- value
- The 64-bit signed integer value to be converted.
true
if value is non-zero;false
if value is zero.
The following example demonstrates converting Int64 values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { long long0 = 0; long long1 = 1; long long2 = -2; bool bool0 = Convert.ToBoolean(long0); bool bool1 = Convert.ToBoolean(long1); bool bool2 = Convert.ToBoolean(long2); Console.WriteLine("(long) {0} as bool = {1}",long0,bool0); Console.WriteLine("(long) {0} as bool = {1}",long1,bool1); Console.WriteLine("(long) {0} as bool = {1}",long2,bool2); } }The output is
(long) 0 as bool = False
(long) 1 as bool = True
(long) -2 as bool = True
System.Convert Class, System Namespace
public static bool ToBoolean(ulong value);
Converts a UInt64 to a Boolean .
- value
- The 64-bit unsigned integer value to be converted.
true
if value is non-zero;false
if value is zero.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToBoolean(System.Object)(Decimal).
The following example demonstrates converting UInt64 values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { ulong ulong0 = 0; ulong ulong1 = 1; bool bool0 = Convert.ToBoolean(ulong0); bool bool1 = Convert.ToBoolean(ulong1); Console.WriteLine("(ulong) {0} as bool = {1}",ulong0,bool0); Console.WriteLine("(ulong) {0} as bool = {1}",ulong1,bool1); } }The output is
(ulong) 0 as bool = False
(ulong) 1 as bool = True
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static bool ToBoolean(string value);
Converts a String to a Boolean .
- value
- The String to be converted.
true
if value equals System.Boolean.TrueString;false
if value equals System.Boolean.FalseString.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value is not equal to System.Boolean.TrueString or System.Boolean.FalseString.
The following example demonstrates converting String values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { string string0 = Boolean.TrueString; string string1 = Boolean.FalseString; string string2 = "foo"; //This is an invalid Boolean. bool bool0 = Convert.ToBoolean(string0); bool bool1 = Convert.ToBoolean(string1); Console.WriteLine("(string) {0} as bool = {1}",string0,bool0); Console.WriteLine("(string) {0} as bool = {1}",string1,bool1); bool bool2 = Convert.ToBoolean(string2); //Throws an exception. Console.WriteLine("(string) {0} as bool = {1}",string2,bool2); } }The output is
(string) True as bool = True (string) False as bool = False Unhandled Exception: System.FormatException: String was not recognized as a valid Boolean. at System.Boolean.Parse(String value) at Convert.ToBoolean(String value) at ConvertBoolTest.Main() in C:\ECMAExamples\ConvertString.cs:line 12
System.Convert Class, System Namespace
public static bool ToBoolean(float value);
Converts a Single to a Boolean .
- value
- The Single value to be converted.
true
if value is non-zero;false
if value is zero.
The following example demonstrates converting Single values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { float float0 = 0.0f; float float1 = 1.0f; float float2 = -2.0f; bool bool0 = Convert.ToBoolean(float0); bool bool1 = Convert.ToBoolean(float1); bool bool2 = Convert.ToBoolean(float2); Console.WriteLine("(float) {0} as bool = {1}",float0,bool0); Console.WriteLine("(float) {0} as bool = {1}",float1,bool1); Console.WriteLine("(float) {0} as bool = {1}",float2,bool2); } }The output is
(float) 0 as bool = False
(float) 1 as bool = True
(float) -2 as bool = True
ExtendedNumerics
System.Convert Class, System Namespace
public static bool ToBoolean(double value);
Converts a Double to a Boolean .
- value
- The Double value to be converted.
true
if value is non-zero;false
if value is zero.
The following example demonstrates converting Double values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { double double0 = 0.0; double double1 = 1.0; double double2 = -2.0; bool bool0 = Convert.ToBoolean(double0); bool bool1 = Convert.ToBoolean(double1); bool bool2 = Convert.ToBoolean(double2); Console.WriteLine("(double) {0} as bool = {1}",double0,bool0); Console.WriteLine("(double) {0} as bool = {1}",double1,bool1); Console.WriteLine("(double) {0} as bool = {1}",double2,bool2); } }The output is
(double) 0 as bool = False
(double) 1 as bool = True
(double) -2 as bool = True
ExtendedNumerics
System.Convert Class, System Namespace
public static bool ToBoolean(decimal value);
Converts a Decimal to a Boolean.
- value
- The Decimal value to be converted.
true
if value is non-zero;false
if value is zero.
The following example demonstrates converting Decimal values to Boolean values.
using System; class ConvertBoolTest { static public void Main() { decimal decimal0 = 0m; decimal decimal1 = 1m; decimal decimal2 = -2m; bool bool0 = Convert.ToBoolean(decimal0); bool bool1 = Convert.ToBoolean(decimal1); bool bool2 = Convert.ToBoolean(decimal2); Console.WriteLine("(decimal) {0} as bool = {1}",decimal0,bool0); Console.WriteLine("(decimal) {0} as bool = {1}",decimal1,bool1); Console.WriteLine("(decimal) {0} as bool = {1}",decimal2,bool2); } }The output is
(decimal) 0 as bool = False
(decimal) 1 as bool = True
(decimal) -2 as bool = True
ExtendedNumerics
System.Convert Class, System Namespace
public static byte ToByte(bool value);
Converts a Boolean to a Byte .
- value
- The Boolean value to be converted.
If value equalstrue
, returns 1; if value equalsfalse
, returns 0.
System.Convert Class, System Namespace
public static byte ToByte(byte value);
Converts a Byte to a Byte .
- value
- The Byte value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
System.Convert Class, System Namespace
public static byte ToByte(char value);
Converts a Char to a Byte .
- value
- The Unicode character to be converted interpreted as an unsigned value.
value as a Byte.
Exception Type Condition OverflowException The numeric value of value is greater than System.Byte.MaxValue.
The following example demonstrates converting Char values to Byte values.
using System; class ConvertByteTest { static public void Main() { char char0 = '0'; char char1 = '1'; char char2 = 'a'; byte byte0 = Convert.ToByte(char0); byte byte1 = Convert.ToByte(char1); byte byte2 = Convert.ToByte(char2); Console.WriteLine("(char) {0} as byte = {1}",char0,byte0); Console.WriteLine("(char) {0} as byte = {1}",char1,byte1); Console.WriteLine("(char) {0} as byte = {1}",char2,byte2); } }The output is
(char) 0 as byte = 48
(char) 1 as byte = 49
(char) a as byte = 97
System.Convert Class, System Namespace
public static byte ToByte(sbyte value);
Converts a SByte to a Byte .
- value
- The 8-bit signed integer to be converted.
value as a Byte.
Exception Type Condition OverflowException value is less than System.Byte.MinValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToByte(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static byte ToByte(short value);
Converts a Int16 to a Byte .
- value
- The 16-bit signed integer value to be converted.
value as a Byte.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue or less than System.Byte.MinValue.
System.Convert Class, System Namespace
public static byte ToByte(ushort value);
Converts a UInt16 to a Byte .
- value
- The 16-bit unsigned integer value to be converted.
value as a Byte.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToByte(System.Object)(Int32).
The following example demonstrates converting UInt16 values to Byte values.
using System; class ConvertByteTest { static public void Main() { ushort ushort0 = 0; ushort ushort1 = 32000; byte byte0 = Convert.ToByte(ushort0); Console.WriteLine("(ushort) {0} as byte = {1}",ushort0,byte0); byte byte1 = Convert.ToByte(ushort1); //Throws an exception. Console.WriteLine("(ushort) {0} as byte = {1}",ushort1,byte1); } }The output is
(ushort) 0 as byte = 0
Exception occurred: System.OverflowException: Value was either too large or too small for an unsigned byte.
at Convert.ToByte(UInt16 value)
at ConvertByteTest.Main() in C:\ECMAExamples\ConvertToByte\ConvertUInt16.cs:line 8
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static byte ToByte(int value);
Converts a Int32 to a Byte .
- value
- The 32-bit signed integer value to be converted.
value as a Byte.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue or less than System.Byte.MinValue.
System.Convert Class, System Namespace
public static byte ToByte(uint value);
Converts a UInt32 to a Byte .
- value
- The 32-bit unsigned integer value to be converted.
value as a Byte.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToByte(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static byte ToByte(long value);
Converts a Int64 to a Byte .
- value
- The 64-bit signed integer value to be converted.
value as a Byte.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue or less than System.Byte.MinValue.
System.Convert Class, System Namespace
public static byte ToByte(ulong value);
Converts a UInt64 to a Byte .
- value
- The 64-bit unsigned integer value to be converted.
value as a Byte.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToByte(System.Object)(Decimal).
The following example demonstrates converting UInt64 values to Byte values.
using System; class ConvertByteTest { static public void Main() { ulong ulong0 = 0; ulong ulong1 = 32000; byte byte0 = Convert.ToByte(ulong0); Console.WriteLine("(ulong) {0} as byte = {1}",ulong0,byte0); byte byte1 = Convert.ToByte(ulong1); //Throws an exception. Console.WriteLine("(ulong) {0} as byte = {1}",ulong1,byte1); } }The output is
(ulong) 0 as byte = 0
Exception occurred: System.OverflowException: Value was either too large or too small for an unsigned byte.
at Convert.ToByte(UInt64 value)
at ConvertByteTest.Main() in C:\ECMAExamples\ConvertToByte\ConvertUInt64.cs:line 8
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static byte ToByte(float value);
Converts a Single to a Byte .
- value
- The Single value to be converted.
value as a Byte , rounded to the nearest integer.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue or less than System.Byte.MinValue, or value is equal to one of System.Single.NaN, System.Single.PositiveInfinity, or System.Single.NegativeInfinity.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
The following example demonstrates converting Single values to Byte values.
using System; class ConvertByteTest { static public void Main() { float float0 = 0.0f; float float1 = 1.5f; float float2 = 2.5f; float float3 = -1.0f; byte byte0 = Convert.ToByte(float0); byte byte1 = Convert.ToByte(float1); byte byte2 = Convert.ToByte(float2); Console.WriteLine("(float) {0} as byte = {1}",float0,byte0); Console.WriteLine("(float) {0} as byte = {1}",float1,byte1); Console.WriteLine("(float) {0} as byte = {1}",float2,byte2); byte byte3 = Convert.ToByte(float3); //Throws an exception. Console.WriteLine("(float) {0} as byte = {1}",float3,byte3); } }The output is
(float) 0 as byte = 0
(float) 1.5 as byte = 2
(float) 2.5 as byte = 2
Exception occurred: System.OverflowException: Value was either too large or too small for an unsigned byte.
at Convert.ToByte(Int32 value)
at Convert.ToByte(Single value)
at ConvertByteTest.Main() in C:\ECMAExamples\ConvertToByte\ConvertFloat.cs:line 15
ExtendedNumerics
System.Convert Class, System Namespace
public static byte ToByte(double value);
Converts a Double to a Byte .
- value
- The Double value to be converted.
value as a Byte , rounded to the nearest integer.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue or less than System.Byte.MinValue, or value is equal to one of System.Double.NaN, System.Double.PositiveInfinity, or System.Double.NegativeInfinity.
Prior to the conversion, if value is halfway between two numbers, it is rounded to the number that has an even digit in the rightmost decimal position. For example, when rounded to two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36
The following example demonstrates converting Double values to Byte values.
using System; class ConvertByteTest { static public void Main() { double double0 = 0.0; double double1 = 1.5; double double2 = 2.5; double double3 = -1.0; byte byte0 = Convert.ToByte(double0); byte byte1 = Convert.ToByte(double1); byte byte2 = Convert.ToByte(double2); Console.WriteLine("(double) {0} as byte = {1}",double0,byte0); Console.WriteLine("(double) {0} as byte = {1}",double1,byte1); Console.WriteLine("(double) {0} as byte = {1}",double2,byte2); byte byte3 = Convert.ToByte(double3); //Throws an exception. Console.WriteLine("(double) {0} as byte = {1}",double3,byte3); } }The output is
(double) 0 as byte = 0
(double) 1.5 as byte = 2
(double) 2.5 as byte = 2
Exception occurred: System.OverflowException: Value was either too large or too small for an unsigned byte.
at Convert.ToByte(Int32 value)
at Convert.ToByte(Double value)
at ConvertByteTest.Main() in C:\ECMAExamples\ConvertToByte\ConvertDouble.cs:line 15
ExtendedNumerics
System.Convert Class, System Namespace
public static byte ToByte(decimal value);
Converts a Decimal to a Byte .
- value
- The Decimal value to be converted.
value as a Byte , rounded to the nearest integer.
Exception Type Condition OverflowException value is greater than System.Byte.MaxValue or less than System.Byte.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6. [Note: This process is known as banker's rounding.]
The following example demonstrates converting Decimal values to Byte values.
using System; class ConvertByteTest { static public void Main() { decimal decimal0 = 0.0m; decimal decimal1 = 1.5m; decimal decimal2 = 2.5m; decimal decimal3 = -1.0m; byte byte0 = Convert.ToByte(decimal0); byte byte1 = Convert.ToByte(decimal1); byte byte2 = Convert.ToByte(decimal2); Console.WriteLine("(decimal) {0} as byte = {1}",decimal0,byte0); Console.WriteLine("(decimal) {0} as byte = {1}",decimal1,byte1); Console.WriteLine("(decimal) {0} as byte = {1}",decimal2,byte2); byte byte3 = Convert.ToByte(decimal3); //Throws an exception. Console.WriteLine("(decimal) {0} as byte = {1}",decimal3,byte3); } }The output is
(decimal) 0 as byte = 0
(decimal) 1.5 as byte = 2
(decimal) 2.5 as byte = 2
Exception occurred: System.OverflowException: Value was either too large or too small for an unsigned byte.
at System.Decimal.ToByte(Decimal value)
at Convert.ToByte(Decimal value)
at ConvertByteTest.Main() in C:\ECMAExamples\ConvertToByte\ConvertDecimal.cs:line 15
ExtendedNumerics
System.Convert Class, System Namespace
public static byte ToByte(string value);
Converts a String representation of a number to a Byte .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
value as a Byte.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value does not consist of an optional sign followed by one or more digits (zero through nine). OverflowException The numeric value of value is greater than System.Byte.MaxValue or less than System.Byte.MinValue.
The following example demonstrates converting String values to Byte values.
using System; class ConvertByteTest { static public void Main() { string string0 = "+22"; string string1 = "0"; string string2 = "-1"; byte byte0 = Convert.ToByte(string0); byte byte1 = Convert.ToByte(string1); Console.WriteLine("(string) {0} as byte = {1}",string0,byte0); Console.WriteLine("(string) {0} as byte = {1}",string1,byte1); byte byte2 = Convert.ToByte(string2); Console.WriteLine("(string) {0} as byte = {1}",string2,byte2); } }The output is
(string) +22 as byte = 22
(string) 0 as byte = 0
Exception occurred: System.OverflowException: Value was either too large or too small for an unsigned byte.
at System.Byte.Parse(String s, NumberStyles style, IFormatProvider provider)
at System.Byte.Parse(String s)
at Convert.ToByte(String value)
at ConvertByteTest.Main() in C:\ECMAExamples\ConvertToByte\ConvertString.cs:line 11
System.Convert Class, System Namespace
public static byte ToByte(string value, IFormatProvider provider);
Converts a String to a Byte .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
value as a Byte.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value does not consist of an optional sign followed by one or more digits (zero through nine). OverflowException The numeric value of value is greater than System.Byte.MaxValue or less than System.Byte.MinValue.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.
System.Convert Class, System Namespace
public static char ToChar(char value);
Converts a Char to a Char .
- value
- The Unicode character to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
System.Convert Class, System Namespace
public static char ToChar(sbyte value);
Converts a SByte to a Char .
- value
- The SByte value to be converted.
value as a Char.
Exception Type Condition OverflowException value is less than System.Char.MinValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToChar(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static char ToChar(byte value);
Converts a Byte to a Char .
- value
- The Byte value to be converted.
value as a Char.
System.Convert Class, System Namespace
public static char ToChar(short value);
Converts a Int16 to a Char .
- value
- The 16-bit signed integer value to be converted.
value as a Char.
Exception Type Condition OverflowException value is less than System.Char.MinValue.
System.Convert Class, System Namespace
public static char ToChar(ushort value);
Converts a UInt16 to a Char .
- value
- The 16-bit unsigned integer value to be converted.
value as a Char.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToChar(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static char ToChar(int value);
Converts a Int32 to a Char .
- value
- The 32-bit signed integer value to be converted.
value as a Char.
Exception Type Condition OverflowException value is greater than System.Char.MaxValue or less than System.Char.MinValue.
System.Convert Class, System Namespace
public static char ToChar(uint value);
Converts a UInt32 to a Char .
- value
- The 32-bit unsigned integer value to be converted.
value as a Char.
Exception Type Condition OverflowException value is greater than System.Char.MaxValue.
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static char ToChar(long value);
Converts a Int64 to a Char .
- value
- The 64-bit signed integer value to be converted.
value as a Char.
Exception Type Condition OverflowException value is greater than System.Char.MaxValue or less than System.Char.MinValue.
System.Convert Class, System Namespace
public static char ToChar(ulong value);
Converts a UInt64 to a Char .
- value
- The 64-bit unsigned integer value to be converted.
value as a Char.
Exception Type Condition OverflowException value is greater than System.Char.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToChar(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static char ToChar(string value);
Converts a String to a Char .
- value
- The String to be converted. The String is required to contain a single character.
value as a Char.
Exception Type Condition FormatException value does not contain exactly one character.
System.Convert Class, System Namespace
public static DateTime ToDateTime(DateTime value);
Converts a DateTime to a DateTime .
- value
- The DateTime to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
System.Convert Class, System Namespace
public static DateTime ToDateTime(string value);
Converts a String to a DateTime structure.
- value
- The String to be converted. The string is in a form allowed by the System.DateTime.Parse(System.String)(String) method.
value as a DateTime.
Exception Type Condition ArgumentException value is a null reference. FormatException value cannot be converted to a DateTime .
This method parses value using the information in a DateTimeFormatInfo instance initialized for the current system culture.
System.Convert Class, System Namespace
public static DateTime ToDateTime(string value, IFormatProvider provider);
Converts a String to a DateTime structure.
- value
- The String to be converted.
- provider
- A IFormatProvider that supplies a DateTimeFormatInfo containing culture-specific formatting information.
value as a DateTime.
Exception Type Condition ArgumentException value is a null reference. FormatException value cannot be converted to a DateTime .
This method parses value using the information in the DateTimeFormatInfo instance supplied by provider. If provider isnull
or if a DateTimeFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.
System.Convert Class, System Namespace
public static decimal ToDecimal(sbyte value);
Converts a SByte to a Decimal .
- value
- The SByte value to be converted.
value as a Decimal.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int16).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(byte value);
Converts a Byte to a Decimal .
- value
- The Byte value to be converted.
value as a Decimal.
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(short value);
Converts a Int16 to a Decimal .
- value
- The 16-bit signed integer value to be converted.
value as a Decimal.
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(ushort value);
Converts a UInt16 to a Decimal .
- value
- The 16-bit unsigned integer value to be converted.
value as a Decimal.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int32).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(int value);
Converts a Int32 to a Decimal .
- value
- The 32-bit signed integer value to be converted.
value as a Decimal.
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(uint value);
Converts a UInt32 to a Decimal .
- value
- The 32-bit unsigned integer value to be converted.
value as a Decimal.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int64).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(long value);
Converts a Int64 to a Decimal .
- value
- The 64-bit signed integer value to be converted.
value as a Decimal.
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(ulong value);
Converts a UInt64 to a Decimal .
- value
- The 64-bit unsigned integer value to be converted.
value as a Decimal.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Decimal).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(float value);
Converts a Single to a Decimal .
- value
- The Single value to be converted.
value as a Decimal. The Decimal contains 7 significant digits and is rounded using banker's rounding.
Exception Type Condition OverflowException The numeric value of value is greater than System.Decimal.MaxValue or less than System.Decimal.MinValue.
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(double value);
Converts a Double to a Decimal .
- value
- The Double value to be converted.
value as a Decimal. The Decimal contains 15 significant digits and is rounded using banker's rounding.
Exception Type Condition OverflowException The numeric value of value is greater than System.Decimal.MaxValue or less than System.Decimal.MinValue.
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(string value);
Converts a String to a Decimal .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Number style.
value as a Decimal.
Exception Type Condition ArgumentException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Decimal.MaxValue or less than System.Decimal.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(string value, IFormatProvider provider);
Converts a String to a Decimal .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Number style.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
value as a Decimal.
Exception Type Condition ArgumentException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Decimal.MaxValue or less than System.Decimal.MinValue.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(decimal value);
Converts a Decimal to a Decimal .
- value
- The Decimal value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
ExtendedNumerics
System.Convert Class, System Namespace
public static decimal ToDecimal(bool value);
Converts a Boolean to a Decimal .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(sbyte value);
Converts a SByte to a Double .
- value
- The SByte value to be converted.
value as a Double.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDouble(System.Object)(Int16).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(byte value);
Converts a Byte to a Double .
- value
- The Byte value to be converted.
value as a Double.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(short value);
Converts a Int16 to a Double .
- value
- The 16-bit signed integer value to be converted.
value as a Double.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(ushort value);
Converts a UInt16 to a Double .
- value
- The 16-bit unsigned integer value to be converted.
value as a Double.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDouble(System.Object)(Int32).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(int value);
Converts a Int32 to a Double .
- value
- The 32-bit signed integer value to be converted.
value as a Double.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(uint value);
Converts a UInt32 to a Double .
- value
- The 32-bit unsigned integer value to be converted.
value as a Double.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDouble(System.Object)(Int64).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(long value);
Converts a Int64 to a Double .
- value
- The 64-bit signed integer value to be converted.
value as a Double.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(ulong value);
Converts a UInt64 to a Double .
- value
- The 64-bit unsigned integer value to be converted.
value as a Double.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDouble(System.Object)(Decimal).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(float value);
Converts a Single to a Double .
- value
- The Single value to be converted.
value as a Double.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(double value);
Converts a Double to a Double .
- value
- The Double value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(decimal value);
Converts a Decimal to a Double .
- value
- The Decimal value to be converted.
value as a Double. value is rounded using banker's rounding.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(string value);
Converts a String to a Double .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowThousands style.
value as a Double.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Double.MaxValue or less than System.Double.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(string value, IFormatProvider provider);
Converts a String to a Double .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowThousands style.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
value as a Double.
Exception Type Condition ArgumentException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Double.MaxValue or less than System.Double.MinValue.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.
ExtendedNumerics
System.Convert Class, System Namespace
public static double ToDouble(bool value);
Converts a Boolean to a Double .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
ExtendedNumerics
System.Convert Class, System Namespace
public static short ToInt16(bool value);
Converts a Boolean to a Int16 .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
System.Convert Class, System Namespace
public static short ToInt16(char value);
Converts a Char to a Int16 .
- value
- The Char to be converted interpreted as an unsigned value.
value as a 16-bit signed integer.
Exception Type Condition OverflowException The numeric value of value is greater than System.Int16.MaxValue.
System.Convert Class, System Namespace
public static short ToInt16(sbyte value);
Converts a SByte to a Int16 .
- value
- The SByte value to be converted.
value as a 16-bit signed integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static short ToInt16(byte value);
Converts a Byte to a Int16 .
- value
- The Byte value to be converted.
value as a 16-bit signed integer.
System.Convert Class, System Namespace
public static short ToInt16(ushort value);
Converts a UInt16 to a Int16 .
- value
- The 16-bit unsigned integer value to be converted.
value as a 16-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int16.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static short ToInt16(int value);
Converts a Int32 to a Int16 .
- value
- The 32-bit signed integer value to be converted.
value as a 16-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int16.MaxValue or less than System.Int16.MinValue.
System.Convert Class, System Namespace
public static short ToInt16(uint value);
Converts a UInt32 to a Int16 .
- value
- The 32-bit unsigned integer value to be converted.
value as a 16-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int16.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static short ToInt16(short value);
Converts a Int16 to a Int16 .
- value
- The 16-bit signed integer value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
System.Convert Class, System Namespace
public static short ToInt16(long value);
Converts a Int64 to a Int16.
- value
- The 64-bit signed integer value to be converted.
value as a 16-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int16.MaxValue or less than System.Int16.MinValue.
System.Convert Class, System Namespace
public static short ToInt16(ulong value);
Converts a UInt64 to a Int16 .
- value
- The 64-bit unsigned integer value to be converted.
value as a 16-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int16.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Decimal).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static short ToInt16(float value);
Converts a Single to a Int16 .
- value
- The Single value to be converted.
value as a 16-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int16.MaxValue or less than System.Int16.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static short ToInt16(double value);
Converts a Double to a Int16 .
- value
- The Double value to be converted.
value as a 16-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int16.MaxValue or less than System.Int16.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static short ToInt16(decimal value);
Converts a Decimal to a Int16 .
- value
- The Decimal value to be converted.
value as a 16-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int16.MaxValue or less than System.Int16.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static short ToInt16(string value);
Converts a String to a Int16 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
value as a 16-bit signed integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Int16.MaxValue or less than System.Int16.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.
System.Convert Class, System Namespace
public static short ToInt16(string value, IFormatProvider provider);
Converts a String to a Int16 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
value as a 16-bit signed integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Int16.MaxValue or less than System.Int16.MinValue .
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.
System.Convert Class, System Namespace
public static int ToInt32(bool value);
Converts a Boolean to a Int32 .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
System.Convert Class, System Namespace
public static int ToInt32(char value);
Converts a Char to a Int32 .
- value
- The Char to be converted interpreted as an unsigned value.
value as a 32-bit signed integer.
System.Convert Class, System Namespace
public static int ToInt32(sbyte value);
Converts a SByte to a Int32 .
- value
- The SByte value to be converted.
value as a 32-bit signed integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static int ToInt32(byte value);
Converts a Byte to a Int32 .
- value
- The Byte value to be converted.
value as a 32-bit signed integer.
System.Convert Class, System Namespace
public static int ToInt32(short value);
Converts a Int16 to a Int32 .
- value
- The 16-bit signed integer value to be converted.
value as a 32-bit signed integer.
System.Convert Class, System Namespace
public static int ToInt32(ushort value);
Converts a UInt16 to a Int32 .
- value
- The 16-bit unsigned integer value to be converted.
value as a 32-bit signed integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static int ToInt32(uint value);
Converts a UInt32 to a Int32 .
- value
- The 32-bit unsigned integer value to be converted.
value as a 32-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int32.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static int ToInt32(int value);
Converts a Int32 to a Int32 .
- value
- The 32-bit signed integer value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
System.Convert Class, System Namespace
public static int ToInt32(long value);
Converts a Int64 to a Int32 .
- value
- The 64-bit signed integer value to be converted.
value as a 32-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int32.MaxValue or less than System.Int32.MinValue.
System.Convert Class, System Namespace
public static int ToInt32(ulong value);
Converts a UInt64 to a Int32 .
- value
- The 64-bit unsigned integer value to be converted.
value as a 32-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int32.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Decimal).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static int ToInt32(float value);
Converts a Single to a Int32 .
- value
- The Single value to be converted.
value as a 32-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int32.MaxValue or less than System.Int32.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static int ToInt32(double value);
Converts a Double to a Int32 .
- value
- The Double value to be converted.
value as a 32-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int32.MaxValue or less than System.Int32.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static int ToInt32(decimal value);
Converts a Decimal to a Int32 .
- value
- The Decimal value to be converted.
value as a 32-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int32.MaxValue or less than System.Int32.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static int ToInt32(string value);
Converts a String to a Int32 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
value as a 32-bit signed integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Int32.MaxValue or less than System.Int32.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.
System.Convert Class, System Namespace
public static int ToInt32(string value, IFormatProvider provider);
Converts a String to a Int32 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
value as a 32-bit signed integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Int32.MaxValue or less than System.Int32.MinValue .
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.
System.Convert Class, System Namespace
public static long ToInt64(bool value);
Converts a Boolean to a Int64 .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
System.Convert Class, System Namespace
public static long ToInt64(char value);
Converts a Char to a Int64 .
- value
- The Char to be converted interpreted as an unsigned value.
value as a 64-bit signed integer.
System.Convert Class, System Namespace
public static long ToInt64(sbyte value);
Converts a SByte to a Int64 .
- value
- The SByte value to be converted.
value as a 64-bit signed integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static long ToInt64(byte value);
Converts a Byte to a Int64 .
- value
- The Byte value to be converted.
value as a 64-bit signed integer.
System.Convert Class, System Namespace
public static long ToInt64(short value);
Converts a Int16 to a Int64 .
- value
- The 16-bit signed integer value to be converted.
value as a 64-bit signed integer.
System.Convert Class, System Namespace
public static long ToInt64(ushort value);
Converts a UInt16 to a Int64 .
- value
- The 16-bit unsigned integer value to be converted.
value as a 64-bit signed integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static long ToInt64(int value);
Converts a Int32 to a Int64 .
- value
- The 32-bit signed integer value to be converted.
value as a 64-bit signed integer.
System.Convert Class, System Namespace
public static long ToInt64(uint value);
Converts a UInt32 to a Int64 .
- value
- The 32-bit unsigned integer value to be converted.
value as a 64-bit signed integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static long ToInt64(ulong value);
Converts a UInt64 to a Int64 .
- value
- The 64-bit unsigned integer value to be converted.
value as a 64-bit signed integer.
Exception Type Condition OverflowException value is greater than System.Int64.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Decimal).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static long ToInt64(long value);
Converts a Int64 to a Int64 .
- value
- The 64-bit signed integer value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
System.Convert Class, System Namespace
public static long ToInt64(float value);
Converts a Single to a Int64 .
- value
- The Single value to be converted.
value as a 64-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int64.MaxValue or less than System.Int64.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static long ToInt64(double value);
Converts a Double to a Int64 .
- value
- The Double value to be converted.
value as a 64-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int64.MaxValue or less than System.Int64.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static long ToInt64(decimal value);
Converts a Decimal to a Int64 .
- value
- The Decimal value to be converted.
value as a 64-bit signed integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.Int64.MaxValue or less than System.Int64.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.
ExtendedNumerics
System.Convert Class, System Namespace
public static long ToInt64(string value);
Converts a String to a Int64 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
value as a 64-bit signed integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Int64.MaxValue or less than System.Int64.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.
System.Convert Class, System Namespace
public static long ToInt64(string value, IFormatProvider provider);
Converts a String to a Int64 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
value as a 64-bit signed integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Int64.MaxValue or less than System.Int64.MinValue.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.
System.Convert Class, System Namespace
public static sbyte ToSByte(bool value);
Converts a Boolean to a SByte .
- value
- The Boolean value to be converted.
If value is truereturns
1; if value isfalse
returns 0.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Boolean).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(sbyte value);
Converts a SByte to a SByte .
- value
- The SByte value to be converted.
value is returned unchanged.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int16).[Note: This method is provided for completeness.]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(char value);
Converts a Char to a SByte .
- value
- The Char to be converted interpreted as an unsigned value.
value as a SByte.
Exception Type Condition OverflowException The numeric value of value is greater than System.SByte.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Char).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(byte value);
Converts a Byte to a SByte .
- value
- The Byte value to be converted.
value as a SByte.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Byte).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(short value);
Converts a Int16 to a SByte .
- value
- The 16-bit signed integer value to be converted.
value as a SByte.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue or less than System.SByte.MinValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(ushort value);
Converts a UInt16 to a SByte .
- value
- The 16-bit unsigned integer value to be converted.
value as a SByte.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(int value);
Converts a Int32 to a SByte .
- value
- The 32-bit signed integer value to be converted.
value as a SByte.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue or less than System.SByte.MinValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(uint value);
Converts a UInt32 to a SByte .
- value
- The 32-bit unsigned integer value to be converted.
value as a SByte.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(long value);
Converts a Int64 to a SByte .
- value
- The 64-bit signed integer value to be converted.
value as a SByte.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue or less than System.SByte.MinValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(ulong value);
Converts a UInt64 to a SByte .
- value
- The 64-bit unsigned integer value to be converted.
value as a SByte.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Decimal).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(float value);
Converts a Single to a SByte .
- value
- The Single value to be converted.
value as a SByte , rounded to the nearest integer.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue or less than System.SByte.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Single).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static sbyte ToSByte(double value);
Converts a Double to a SByte .
- value
- The Double value to be converted.
value as a SByte , rounded to the nearest integer.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue or less than System.SByte.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Double).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static sbyte ToSByte(decimal value);
Converts a Decimal to a SByte .
- value
- The Decimal value to be converted.
value as a SByte , rounded to the nearest integer.
Exception Type Condition OverflowException value is greater than System.SByte.MaxValue or less than System.SByte.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Decimal).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static sbyte ToSByte(string value);
Converts a String representation of a number to a SByte .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
value as a SByte.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value in the specified format. OverflowException The numeric value of value is greater than System.SByte.MaxValue or less than System.SByte.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(String).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static sbyte ToSByte(string value, IFormatProvider provider);
Converts a String to a SByte .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
value as a SByte.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(String, IFormatProvider ).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static float ToSingle(sbyte value);
Converts a SByte to a Single .
- value
- The SByte value to be converted.
value as a Single.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToSingle(System.Object)(Int16).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(byte value);
Converts a Byte to a Single .
- value
- The Byte value to be converted.
value as a Single.
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(short value);
Converts a Int16 to a Single .
- value
- The 16-bit signed integer value to be converted.
value as a Single.
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(ushort value);
Converts a UInt16 to a Single .
- value
- The 16-bit unsigned integer value to be converted.
value as a Single.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToSingle(System.Object)(Int32).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(int value);
Converts a Int32 to a Single .
- value
- The 32-bit signed integer value to be converted.
value as a Single.
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(uint value);
Converts a UInt32 to a Single .
- value
- The 32-bit unsigned integer value to be converted.
value as a Single.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToSingle(System.Object)(Int64).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(long value);
Converts a Int64 to a Single .
- value
- The 64-bit signed integer value to be converted.
value as a Single.
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(ulong value);
Converts a UInt64 to a Single .
- value
- The 64-bit unsigned integer value to be converted.
value as a Single.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToSingle(System.Object)(Decimal).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(float value);
Converts a Single to a Single .
- value
- The Single value to be converted.
value as a Single .
[Note: This method is provided for completeness.]
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(double value);
Converts a Double to a Single .
- value
- The Double value to be converted.
value as a Single.
Exception Type Condition OverflowException value is greater than System.Single.MaxValue or less than System.Single.MinValue.
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(decimal value);
Converts a Decimal to a Single .
- value
- The Decimal value to be converted.
value as a Single. value is rounded using banker's rounding.
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(string value);
Converts a String to a Single .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowThousands style.
value as a Single.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Single.MaxValue or less than System.Single.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(string value, IFormatProvider provider);
Converts a String to a Single .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowThousands style.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
value as a Single.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.Single.MaxValue or less than System.Single.MinValue.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.
ExtendedNumerics
System.Convert Class, System Namespace
public static float ToSingle(bool value);
Converts a Boolean to a Single .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
ExtendedNumerics
System.Convert Class, System Namespace
public static string ToString(bool value);
Converts a Boolean to a String .
- value
- The Boolean value to be converted.
Returns the value returned by value .ToString().
[Note: See System.Boolean.ToString.]
System.Convert Class, System Namespace
public static string ToString(char value);
Converts a Char to a String .
- value
- The Char to be converted.
value as a String.
System.Convert Class, System Namespace
public static string ToString(sbyte value);
Converts a SByte to a String .
- value
- The SByte value to be converted.
Returns the value returned by value.ToString().
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int16).[Note: See System.SByte.ToString.]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static string ToString(sbyte value, IFormatProvider provider);
Converts a SByte to a String .
- value
- The SByte value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int16, IFormatProvider).This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider is
null
or if a NumberFormatInfo cannot be obtained from provider , the string is formatted in accordance with the current system culture.[Note: See System.SByte.ToString.]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static string ToString(byte value);
Converts a Byte to a String .
- value
- The Byte value to be converted.
Returns the value returned by value.ToString().
[Note: See System.Byte.ToString.]
System.Convert Class, System Namespace
public static string ToString(byte value, IFormatProvider provider);
Converts a Byte to a String .
- value
- The Byte value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.Byte.ToString.]
System.Convert Class, System Namespace
public static string ToString(short value);
Converts a Int16 to a String .
- value
- The 16-bit signed integer value to be converted.
Returns the value returned by value.ToString().
[Note: See System.Int16.ToString.]
System.Convert Class, System Namespace
public static string ToString(short value, IFormatProvider provider);
Converts a Int16 to a String .
- value
- The 16-bit signed integer value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.Int16.ToString.]
System.Convert Class, System Namespace
public static string ToString(ushort value);
Converts a UInt16 to a String .
- value
- The 16-bit unsigned integer value to be converted.
Returns the value returned by value.ToString().
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int32).[Note: See System.UInt16.ToString.]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static string ToString(ushort value, IFormatProvider provider);
Converts a UInt16 to a String .
- value
- The 16-bit unsigned integer value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int32, IFormatProvider).This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider is
null
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.UInt16.ToString.]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static string ToString(int value);
Converts a Int32 to a String .
- value
- The 32-bit signed integer value to be converted.
Returns the value returned by value.ToString().
[Note: See System.Int32.ToString.]
System.Convert Class, System Namespace
public static string ToString(int value, IFormatProvider provider);
Converts a Int32 to a String .
- value
- The 32-bit signed integer value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.Int32.ToString .]
System.Convert Class, System Namespace
public static string ToString(uint value);
Converts a UInt32 to a String .
- value
- The 32-bit unsigned integer value to be converted.
Returns the value returned by value.ToString().
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int64).[Note: See System.UInt32.ToString.]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static string ToString(uint value, IFormatProvider provider);
Converts a UInt32 to a String .
- value
- The 32-bit unsigned integer value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int64, IFormatProvider).This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider is
null
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.UInt32.ToString.]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static string ToString(long value);
Converts a Int64 to a String .
- value
- The 64-bit signed integer value to be converted.
Returns the value returned by value.ToString().
[Note: See System.Int64.ToString.]
System.Convert Class, System Namespace
public static string ToString(long value, IFormatProvider provider);
Converts a Int64 to a String .
- value
- The 64-bit signed integer value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.Int64.ToString.]
System.Convert Class, System Namespace
public static string ToString(ulong value);
Converts a UInt64 to a String .
- value
- The 64-bit unsigned integer value to be converted.
Returns the value returned by value.ToString().
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Decimal).[Note: See System.UInt64.ToString.]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static string ToString(ulong value, IFormatProvider provider);
Converts a UInt64 to a String .
- value
- The 64-bit unsigned integer value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Decimal, IFormatProvider).This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider is
null
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.UInt64.ToString .]
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static string ToString(float value);
Converts a Single to a String .
- value
- The Single value to be converted.
Returns the value returned by value.ToString().
[Note: See System.Single.ToString.]
ExtendedNumerics
System.Convert Class, System Namespace
public static string ToString(float value, IFormatProvider provider);
Converts a Single to a String .
- value
- The Single value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.Single.ToString.]
ExtendedNumerics
System.Convert Class, System Namespace
public static string ToString(double value);
Converts a Double to a String .
- value
- The Double value to be converted.
Returns the value returned by value.ToString().
[Note: See System.Double.ToString.]
ExtendedNumerics
System.Convert Class, System Namespace
public static string ToString(double value, IFormatProvider provider);
Converts a Double to a String .
- value
- The Double value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.Double.ToString.]
ExtendedNumerics
System.Convert Class, System Namespace
public static string ToString(decimal value);
Converts a Decimal to a String .
- value
- The Decimal value to be converted.
Returns the value returned by value.ToString().
[Note: See System.Decimal.ToString.]
ExtendedNumerics
System.Convert Class, System Namespace
public static string ToString(decimal value, IFormatProvider provider);
Converts a Decimal to a String .
- value
- The Decimal value to be converted.
- provider
- A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This method converts value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.Decimal.ToString.]
ExtendedNumerics
System.Convert Class, System Namespace
public static string ToString(DateTime value);
Converts a DateTime value to a String .
- value
- The DateTime value to be converted.
Returns the value returned by value.ToString().
[Note: See System.DateTime.ToString.]
System.Convert Class, System Namespace
public static string ToString(DateTime value, IFormatProvider provider);
Converts a DateTime value to a String .
- value
- The DateTime value to be converted.
- provider
- A IFormatProvider that supplies a DateTimeFormatInfo containing culture-specific formatting information.
Returns the value returned by value.ToString(provider).
This method converts value using the information in the DateTimeFormatInfo instance supplied by provider. If provider isnull
or if a DateTimeFormatInfo cannot be obtained from provider, the string is formatted in accordance with the current system culture.[Note: See System.DateTime.ToString.]
System.Convert Class, System Namespace
public static string ToString(string value);
Returns the specified string.
- value
- A String.
value is returned unchanged.
[Note: This method is provided for completeness.]
System.Convert Class, System Namespace
public static ushort ToUInt16(bool value);
Converts a Boolean to a UInt16 .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Boolean).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(char value);
Converts a Char to a UInt16 .
- value
- The Char to be converted interpreted as an unsigned value.
value as a 16-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Char).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(sbyte value);
Converts a SByte to a UInt16 .
- value
- The SByte value to be converted.
value as a 16-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt16.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(byte value);
Converts a Byte to a UInt16 .
- value
- The Byte value to be converted.
value as a 16-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Byte).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(short value);
Converts a Int16 to a UInt16 .
- value
- The 16-bit signed integer value to be converted.
value as a 16-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt16.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(int value);
Converts a Int32 to a UInt16 .
- value
- The 32-bit signed integer value to be converted.
value as a 16-bit unsigned integer.
Exception Type Condition OverflowException value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(ushort value);
Converts a UInt16 to a UInt16 .
- value
- The 16-bit unsigned integer value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(uint value);
Converts a UInt32 to a UInt16 .
- value
- The 32-bit unsigned integer value to be converted.
value as a 16-bit unsigned integer.
Exception Type Condition OverflowException value is greater than System.UInt16.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(long value);
Converts a Int64 to a UInt16 .
- value
- The 64-bit signed integer value to be converted.
value as a 16-bit unsigned integer.
Exception Type Condition OverflowException value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(ulong value);
Converts a UInt64 to a UInt16 .
- value
- The 64-bit unsigned integer value to be converted.
value as a 16-bit unsigned integer.
Exception Type Condition OverflowException value is greater than System.UInt16.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Decimal).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(float value);
Converts a Single to a UInt16 .
- value
- The Single value to be converted.
value as a 16-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Single).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static ushort ToUInt16(double value);
Converts a Double to a UInt16 .
- value
- The Double value to be converted.
value as a 16-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Double).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static ushort ToUInt16(decimal value);
Converts a Decimal to a UInt16 .
- value
- The Decimal value to be converted.
value as a 16-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Decimal).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static ushort ToUInt16(string value);
Converts a String to a UInt16 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
value as a 16-bit unsigned integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(String).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ushort ToUInt16(string value, IFormatProvider provider);
Converts a String to a UInt16 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
- provider
- An object that implements the IFormatProvider interface and supplies a NumberFormatInfo instance containing culture-specific formatting information.
value as a 16-bit unsigned integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(String, IFormatProvider).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(bool value);
Converts a Boolean to a UInt32 .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Boolean).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(char value);
Converts a Char to a UInt32 .
- value
- The Char to be converted interpreted as an unsigned value.
value as a 32-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Char).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(sbyte value);
Converts a SByte to a UInt32 .
- value
- The SByte value to be converted.
value as a 32-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt32.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(byte value);
Converts a Byte to a UInt32 .
- value
- The Byte value to be converted.
value as a 32-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Byte).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(short value);
Converts a Int16 to a UInt32 .
- value
- The 16-bit signed integer value to be converted.
value as a 32-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt32.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(ushort value);
Converts a UInt16 to a UInt32 .
- value
- The 16-bit unsigned integer value to be converted.
value as a 32-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(int value);
Converts a Int32 to a UInt32 .
- value
- The 32-bit signed integer value to be converted.
value as a 32-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt32.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(uint value);
Converts a UInt32 to a UInt32 .
- value
- The 32-bit unsigned integer value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(long value);
Converts a Int64 to a UInt32 .
- value
- The 64-bit signed integer value to be converted.
value as a 32-bit unsigned integer.
Exception Type Condition OverflowException value is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(ulong value);
Converts a UInt64 to a UInt32 .
- value
- The 64-bit unsigned integer value to be converted.
value as a 32-bit unsigned integer.
Exception Type Condition OverflowException value is greater than System.UInt32.MaxValue.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Decimal).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(float value);
Converts a Single to a UInt32 .
- value
- The Single value to be converted.
value as a 32-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Single).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static uint ToUInt32(double value);
Converts a Double to a UInt32 .
- value
- The Double value to be converted.
value as a 32-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Double).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static uint ToUInt32(decimal value);
Converts a Decimal to a UInt32 .
- value
- The Decimal value to be converted.
value as a 32-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Decimal).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static uint ToUInt32(string value);
Converts a String to a UInt32 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
value as a 32-bit unsigned integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(String).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static uint ToUInt32(string value, IFormatProvider provider);
Converts a String to a UInt32 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
- provider
- An object that implements the IFormatProvider interface and supplies a NumberFormatInfo instance containing culture-specific formatting information.
value as an 32-bit unsigned integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(String, IFormatProvider ).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(bool value);
Converts a Boolean to a UInt64 .
- value
- The Boolean value to be converted.
If value istrue
returns 1; if value isfalse
returns 0.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Boolean).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(char value);
Converts a Char to a UInt64 .
- value
- The Char to be converted interpreted as an unsigned value.
value as a 64-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Char).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(sbyte value);
Converts a SByte to a UInt64 .
- value
- The SByte value to be converted.
value as a 64-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt64.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(byte value);
Converts a Byte to a UInt64 .
- value
- The Byte value to be converted.
value as a 64-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Byte).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(short value);
Converts a Int16 to a UInt64 .
- value
- The 16-bit signed integer value to be converted.
value as a 64-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt64.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int16).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(ushort value);
Converts a UInt16 to a UInt64 .
- value
- The 16-bit unsigned integer value to be converted.
value as a 64-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(int value);
Converts a Int32 to a UInt64 .
- value
- The 32-bit signed integer value to be converted.
value as a 64-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt64.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int32).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(uint value);
Converts a UInt32 to a UInt64 .
- value
- The 32-bit unsigned integer value to be converted.
value as a 64-bit unsigned integer.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(long value);
Converts a Int64 to a UInt64 .
- value
- The 64-bit signed integer value to be converted.
value as a 64-bit unsigned integer.
Exception Type Condition OverflowException value is less than System.UInt64.MinValue .
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int64).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(ulong value);
Converts a UInt64 to a UInt64 .
- value
- The 64-bit unsigned integer value to be converted.
value is returned unchanged.
[Note: This method is provided for completeness.]
This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Decimal).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(float value);
Converts a Single to a UInt64 .
- value
- The Single value to be converted.
value as a 64-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Single).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static ulong ToUInt64(double value);
Converts a Double to a UInt64 .
- value
- The Double value to be converted.
value as a 64-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Double).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static ulong ToUInt64(decimal value);
Converts a Decimal to a UInt64 .
- value
- The Decimal value to be converted.
value as a 64-bit unsigned integer. value is rounded prior to conversion.
Exception Type Condition OverflowException value is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.
Prior to the conversion, if value is halfway between two whole numbers, it is rounded to the nearest even integer. For example, 4.5 is rounded to 4, and 5.5 is rounded to 6.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Decimal).
CLSCompliantAttribute(false)
ExtendedNumerics
System.Convert Class, System Namespace
public static ulong ToUInt64(string value);
Converts a String to a UInt64 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
value as a 64-bit unsigned integer.
Exception Type Condition ArgumentNullException value is null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.
This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(String).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace
public static ulong ToUInt64(string value, IFormatProvider provider);
Converts a String to a UInt64 .
- value
- The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.
- provider
- A Object that implements the IFormatProvider interface and supplies a NumberFormatInfo instance containing culture-specific formatting information.
value as a 64-bit unsigned integer.
Exception Type Condition ArgumentNullException value is a null reference. FormatException value cannot be converted to a numeric value. OverflowException The numeric value of value is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.
This method parses value using the information in the NumberFormatInfo instance supplied by provider. If provider isnull
or if a NumberFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int64, IFormatProvider ).
CLSCompliantAttribute(false)
System.Convert Class, System Namespace