System.Convert Class

public sealed class Convert

Base Types

Object
  Convert

Assembly

mscorlib

Library

BCL

Summary

Performs conversions between base data types.

Description

The following table shows conversions from source types to destination types. The first column contains the source types. The remaining columns indicate the destination types the source can be converted to. An 'x' indicates the Convert class implements the conversion. [Note: the column headers correspond precisely, in order, to the source types in the first column, but have been abbreviated to fit.]

TypeBool
Booleanx
Bytex
Char
DateTime
Decimalx
Doublex
Int16x
Int32x
Int64x
SBytex
Singlex
Stringx
UInt16x
UInt32x
UInt64x
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 might 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.

See Also

System Namespace

Members

Convert Methods

Convert.ToBoolean(System.Decimal) Method
Convert.ToBoolean(double) Method
Convert.ToBoolean(float) Method
Convert.ToBoolean(System.String) Method
Convert.ToBoolean(ulong) Method
Convert.ToBoolean(long) Method
Convert.ToBoolean(uint) Method
Convert.ToBoolean(int) Method
Convert.ToBoolean(ushort) Method
Convert.ToBoolean(short) Method
Convert.ToBoolean(byte) Method
Convert.ToBoolean(sbyte) Method
Convert.ToBoolean(bool) Method
Convert.ToByte(System.String) Method
Convert.ToByte(System.Decimal) Method
Convert.ToByte(double) Method
Convert.ToByte(float) Method
Convert.ToByte(ulong) Method
Convert.ToByte(long) Method
Convert.ToByte(uint) Method
Convert.ToByte(int) Method
Convert.ToByte(ushort) Method
Convert.ToByte(short) Method
Convert.ToByte(sbyte) Method
Convert.ToByte(bool) Method
Convert.ToByte(byte) Method
Convert.ToByte(char) Method
Convert.ToByte(System.String, System.IFormatProvider) Method
Convert.ToChar(System.String) Method
Convert.ToChar(ulong) Method
Convert.ToChar(long) Method
Convert.ToChar(uint) Method
Convert.ToChar(int) Method
Convert.ToChar(ushort) Method
Convert.ToChar(short) Method
Convert.ToChar(byte) Method
Convert.ToChar(sbyte) Method
Convert.ToChar(char) Method
Convert.ToDateTime(System.DateTime) Method
Convert.ToDateTime(System.String) Method
Convert.ToDateTime(System.String, System.IFormatProvider) Method
Convert.ToDecimal(bool) Method
Convert.ToDecimal(System.Decimal) Method
Convert.ToDecimal(System.String, System.IFormatProvider) Method
Convert.ToDecimal(System.String) Method
Convert.ToDecimal(double) Method
Convert.ToDecimal(float) Method
Convert.ToDecimal(ulong) Method
Convert.ToDecimal(long) Method
Convert.ToDecimal(uint) Method
Convert.ToDecimal(int) Method
Convert.ToDecimal(ushort) Method
Convert.ToDecimal(short) Method
Convert.ToDecimal(byte) Method
Convert.ToDecimal(sbyte) Method
Convert.ToDouble(double) Method
Convert.ToDouble(float) Method
Convert.ToDouble(ulong) Method
Convert.ToDouble(long) Method
Convert.ToDouble(uint) Method
Convert.ToDouble(int) Method
Convert.ToDouble(ushort) Method
Convert.ToDouble(short) Method
Convert.ToDouble(byte) Method
Convert.ToDouble(sbyte) Method
Convert.ToDouble(bool) Method
Convert.ToDouble(System.Decimal) Method
Convert.ToDouble(System.String) Method
Convert.ToDouble(System.String, System.IFormatProvider) Method
Convert.ToInt16(System.Decimal) Method
Convert.ToInt16(System.String) Method
Convert.ToInt16(System.String, System.IFormatProvider) Method
Convert.ToInt16(double) Method
Convert.ToInt16(float) Method
Convert.ToInt16(ulong) Method
Convert.ToInt16(long) Method
Convert.ToInt16(short) Method
Convert.ToInt16(uint) Method
Convert.ToInt16(int) Method
Convert.ToInt16(ushort) Method
Convert.ToInt16(byte) Method
Convert.ToInt16(sbyte) Method
Convert.ToInt16(char) Method
Convert.ToInt16(bool) Method
Convert.ToInt32(bool) Method
Convert.ToInt32(System.String, System.IFormatProvider) Method
Convert.ToInt32(System.String) Method
Convert.ToInt32(System.Decimal) Method
Convert.ToInt32(double) Method
Convert.ToInt32(float) Method
Convert.ToInt32(ulong) Method
Convert.ToInt32(long) Method
Convert.ToInt32(int) Method
Convert.ToInt32(uint) Method
Convert.ToInt32(ushort) Method
Convert.ToInt32(short) Method
Convert.ToInt32(byte) Method
Convert.ToInt32(sbyte) Method
Convert.ToInt32(char) Method
Convert.ToInt64(char) Method
Convert.ToInt64(bool) 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(System.String, System.IFormatProvider) Method
Convert.ToSingle(System.String) Method
Convert.ToSingle(System.Decimal) Method
Convert.ToSingle(double) Method
Convert.ToSingle(float) Method
Convert.ToSingle(ulong) Method
Convert.ToSingle(long) Method
Convert.ToSingle(uint) Method
Convert.ToSingle(int) Method
Convert.ToSingle(ushort) Method
Convert.ToSingle(short) Method
Convert.ToSingle(byte) Method
Convert.ToSingle(sbyte) Method
Convert.ToSingle(bool) 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(uint) Method
Convert.ToString(int, System.IFormatProvider) Method
Convert.ToString(int) Method
Convert.ToString(ushort, System.IFormatProvider) Method
Convert.ToString(ushort) Method
Convert.ToString(short, System.IFormatProvider) Method
Convert.ToString(short) Method
Convert.ToString(byte, System.IFormatProvider) Method
Convert.ToString(byte) Method
Convert.ToString(sbyte, System.IFormatProvider) Method
Convert.ToString(sbyte) Method
Convert.ToString(char) Method
Convert.ToString(bool) Method
Convert.ToString(System.String) Method
Convert.ToUInt16(System.String, System.IFormatProvider) Method
Convert.ToUInt16(System.String) Method
Convert.ToUInt16(System.Decimal) Method
Convert.ToUInt16(double) Method
Convert.ToUInt16(float) Method
Convert.ToUInt16(ulong) Method
Convert.ToUInt16(long) Method
Convert.ToUInt16(uint) Method
Convert.ToUInt16(ushort) Method
Convert.ToUInt16(int) Method
Convert.ToUInt16(short) Method
Convert.ToUInt16(byte) Method
Convert.ToUInt16(sbyte) Method
Convert.ToUInt16(char) Method
Convert.ToUInt16(bool) 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(System.String, System.IFormatProvider) Method
Convert.ToUInt64(System.String) Method
Convert.ToUInt64(System.Decimal) Method
Convert.ToUInt64(double) Method
Convert.ToUInt64(float) Method
Convert.ToUInt64(ulong) Method
Convert.ToUInt64(long) Method
Convert.ToUInt64(uint) Method
Convert.ToUInt64(int) Method
Convert.ToUInt64(ushort) Method
Convert.ToUInt64(short) Method
Convert.ToUInt64(byte) Method
Convert.ToUInt64(sbyte) Method
Convert.ToUInt64(char) Method
Convert.ToUInt64(bool) Method


Convert.ToBoolean(System.Decimal) Method

public static bool ToBoolean(decimal value);

Summary

Converts a Decimal to a Boolean.

Parameters

value
The Decimal value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Example

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

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(double) Method

public static bool ToBoolean(double value);

Summary

Converts a Double to a Boolean .

Parameters

value
The Double value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Example

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

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(float) Method

public static bool ToBoolean(float value);

Summary

Converts a Single to a Boolean .

Parameters

value
The Single value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Example

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

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(System.String) Method

public static bool ToBoolean(string value);

Summary

Converts a String to a Boolean .

Parameters

value
The String to be converted.

Return Value

true if value equals System.Boolean.TrueString; false if value equals System.Boolean.FalseString.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue is not equal to System.Boolean.TrueString or System.Boolean.FalseString.

Example

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

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(ulong) Method

public static bool ToBoolean(ulong value);

Summary

Converts a UInt64 to a Boolean .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToBoolean(System.Object)(Decimal).

Example

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

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(long) Method

public static bool ToBoolean(long value);

Summary

Converts a Int64 to a Boolean .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Example

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

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(uint) Method

public static bool ToBoolean(uint value);

Summary

Converts a UInt32 to a Boolean .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToBoolean(System.Object)(Int64).

Example

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

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(int) Method

public static bool ToBoolean(int value);

Summary

Converts a Int32 to a Boolean .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Example

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

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(ushort) Method

public static bool ToBoolean(ushort value);

Summary

Converts a UInt16 to a Boolean .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToBoolean(System.Object)(Int32).

Example

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

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(short) Method

public static bool ToBoolean(short value);

Summary

Converts a Int16 to a Boolean .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Example

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

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(byte) Method

public static bool ToBoolean(byte value);

Summary

Converts a Byte to a Boolean .

Parameters

value
The Byte value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Example

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

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(sbyte) Method

public static bool ToBoolean(sbyte value);

Summary

Converts a SByte to a Boolean .

Parameters

value
The 8-bit signed integer value to be converted.

Return Value

true if value is non-zero; false if value is zero.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToBoolean(System.Object)(Int16).

Example

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

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToBoolean(bool) Method

public static bool ToBoolean(bool value);

Summary

Converts a Boolean to a Boolean .

Parameters

value
The Boolean value to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

See Also

System.Convert Class, System Namespace

Convert.ToByte(System.String) Method

public static byte ToByte(string value);

Summary

Converts a String representation of a number to a Byte .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue does not consist of an optional sign followed by one or more digits (zero through nine).
OverflowExceptionThe numeric value of value is greater than System.Byte.MaxValue or less than System.Byte.MinValue.

Example

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

See Also

System.Convert Class, System Namespace

Convert.ToByte(System.Decimal) Method

public static byte ToByte(decimal value);

Summary

Converts a Decimal to a Byte .

Parameters

value
The Decimal value to be converted.

Return Value

value as a Byte , rounded to the nearest integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Byte.MaxValue or less than System.Byte.MinValue.

Description

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.]

Example

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

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToByte(double) Method

public static byte ToByte(double value);

Summary

Converts a Double to a Byte .

Parameters

value
The Double value to be converted.

Return Value

value as a Byte , rounded to the nearest integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue 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.

Description

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

Example

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

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToByte(float) Method

public static byte ToByte(float value);

Summary

Converts a Single to a Byte .

Parameters

value
The Single value to be converted.

Return Value

value as a Byte , rounded to the nearest integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue 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.

Description

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.

Example

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

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToByte(ulong) Method

public static byte ToByte(ulong value);

Summary

Converts a UInt64 to a Byte .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Byte.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToByte(System.Object)(Decimal).

Example

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

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToByte(long) Method

public static byte ToByte(long value);

Summary

Converts a Int64 to a Byte .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Byte.MaxValue or less than System.Byte.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToByte(uint) Method

public static byte ToByte(uint value);

Summary

Converts a UInt32 to a Byte .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Byte.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToByte(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToByte(int) Method

public static byte ToByte(int value);

Summary

Converts a Int32 to a Byte .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Byte.MaxValue or less than System.Byte.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToByte(ushort) Method

public static byte ToByte(ushort value);

Summary

Converts a UInt16 to a Byte .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Byte.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToByte(System.Object)(Int32).

Example

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

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToByte(short) Method

public static byte ToByte(short value);

Summary

Converts a Int16 to a Byte .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Byte.MaxValue or less than System.Byte.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToByte(sbyte) Method

public static byte ToByte(sbyte value);

Summary

Converts a SByte to a Byte .

Parameters

value
The 8-bit signed integer to be converted.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.Byte.MinValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToByte(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToByte(bool) Method

public static byte ToByte(bool value);

Summary

Converts a Boolean to a Byte .

Parameters

value
The Boolean value to be converted.

Return Value

If value equals true , returns 1; if value equals false , returns 0.

See Also

System.Convert Class, System Namespace

Convert.ToByte(byte) Method

public static byte ToByte(byte value);

Summary

Converts a Byte to a Byte .

Parameters

value
The Byte value to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

See Also

System.Convert Class, System Namespace

Convert.ToByte(char) Method

public static byte ToByte(char value);

Summary

Converts a Char to a Byte .

Parameters

value
The Unicode character to be converted interpreted as an unsigned value.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
OverflowExceptionThe numeric value of value is greater than System.Byte.MaxValue.

Example

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

See Also

System.Convert Class, System Namespace

Convert.ToByte(System.String, System.IFormatProvider) Method

public static byte ToByte(string value, IFormatProvider provider);

Summary

Converts a String to a Byte .

Parameters

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.

Return Value

value as a Byte.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue does not consist of an optional sign followed by one or more digits (zero through nine).
OverflowExceptionThe numeric value of value is greater than System.Byte.MaxValue or less than System.Byte.MinValue.

Description

This method parses 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 parsed using the formatting information of the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToChar(System.String) Method

public static char ToChar(string value);

Summary

Converts a String to a Char .

Parameters

value
The String to be converted. The String is required to contain a single character.

Return Value

value as a Char.

Exceptions

Exception TypeCondition
FormatExceptionvalue does not contain exactly one character.

See Also

System.Convert Class, System Namespace

Convert.ToChar(ulong) Method

public static char ToChar(ulong value);

Summary

Converts a UInt64 to a Char .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a Char.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Char.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToChar(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToChar(long) Method

public static char ToChar(long value);

Summary

Converts a Int64 to a Char .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a Char.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Char.MaxValue or less than System.Char.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToChar(uint) Method

public static char ToChar(uint value);

Summary

Converts a UInt32 to a Char .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a Char.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Char.MaxValue.

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToChar(int) Method

public static char ToChar(int value);

Summary

Converts a Int32 to a Char .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a Char.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Char.MaxValue or less than System.Char.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToChar(ushort) Method

public static char ToChar(ushort value);

Summary

Converts a UInt16 to a Char .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a Char.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToChar(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToChar(short) Method

public static char ToChar(short value);

Summary

Converts a Int16 to a Char .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a Char.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.Char.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToChar(byte) Method

public static char ToChar(byte value);

Summary

Converts a Byte to a Char .

Parameters

value
The Byte value to be converted.

Return Value

value as a Char.

See Also

System.Convert Class, System Namespace

Convert.ToChar(sbyte) Method

public static char ToChar(sbyte value);

Summary

Converts a SByte to a Char .

Parameters

value
The SByte value to be converted.

Return Value

value as a Char.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.Char.MinValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToChar(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToChar(char) Method

public static char ToChar(char value);

Summary

Converts a Char to a Char .

Parameters

value
The Unicode character to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

See Also

System.Convert Class, System Namespace

Convert.ToDateTime(System.DateTime) Method

public static DateTime ToDateTime(DateTime value);

Summary

Converts a DateTime to a DateTime .

Parameters

value
The DateTime to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

See Also

System.Convert Class, System Namespace

Convert.ToDateTime(System.String) Method

public static DateTime ToDateTime(string value);

Summary

Converts a String to a DateTime structure.

Parameters

value
The String to be converted. The string is in a form allowed by the System.DateTime.Parse(System.String)(String) method.

Return Value

value as a DateTime.

Exceptions

Exception TypeCondition
ArgumentExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a DateTime .

Description

This method parses value using the information in a DateTimeFormatInfo instance initialized for the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToDateTime(System.String, System.IFormatProvider) Method

public static DateTime ToDateTime(string value, IFormatProvider provider);

Summary

Converts a String to a DateTime structure.

Parameters

value
The String to be converted.
provider
A IFormatProvider that supplies a DateTimeFormatInfo containing culture-specific formatting information.

Return Value

value as a DateTime.

Exceptions

Exception TypeCondition
ArgumentExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a DateTime .

Description

This method parses value using the information in the DateTimeFormatInfo instance supplied by provider. If provider is null or if a DateTimeFormatInfo cannot be obtained from provider, the string is parsed using the formatting information of the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(bool) Method

public static decimal ToDecimal(bool value);

Summary

Converts a Boolean to a Decimal .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(System.Decimal) Method

public static decimal ToDecimal(decimal value);

Summary

Converts a Decimal to a Decimal .

Parameters

value
The Decimal value to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(System.String, System.IFormatProvider) Method

public static decimal ToDecimal(string value, IFormatProvider provider);

Summary

Converts a String to a Decimal .

Parameters

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.

Return Value

value as a Decimal.

Exceptions

Exception TypeCondition
ArgumentExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Decimal.MaxValue or less than System.Decimal.MinValue.

Description

This method parses 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 parsed using the formatting information of the current system culture.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(System.String) Method

public static decimal ToDecimal(string value);

Summary

Converts a String to a Decimal .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Number style.

Return Value

value as a Decimal.

Exceptions

Exception TypeCondition
ArgumentExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Decimal.MaxValue or less than System.Decimal.MinValue.

Description

This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(double) Method

public static decimal ToDecimal(double value);

Summary

Converts a Double to a Decimal .

Parameters

value
The Double value to be converted.

Return Value

value as a Decimal. The Decimal contains 15 significant digits and is rounded using banker's rounding.

Exceptions

Exception TypeCondition
OverflowExceptionThe numeric value of value is greater than System.Decimal.MaxValue or less than System.Decimal.MinValue.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(float) Method

public static decimal ToDecimal(float value);

Summary

Converts a Single to a Decimal .

Parameters

value
The Single value to be converted.

Return Value

value as a Decimal. The Decimal contains 7 significant digits and is rounded using banker's rounding.

Exceptions

Exception TypeCondition
OverflowExceptionThe numeric value of value is greater than System.Decimal.MaxValue or less than System.Decimal.MinValue.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(ulong) Method

public static decimal ToDecimal(ulong value);

Summary

Converts a UInt64 to a Decimal .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a Decimal.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(long) Method

public static decimal ToDecimal(long value);

Summary

Converts a Int64 to a Decimal .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a Decimal.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(uint) Method

public static decimal ToDecimal(uint value);

Summary

Converts a UInt32 to a Decimal .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a Decimal.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(int) Method

public static decimal ToDecimal(int value);

Summary

Converts a Int32 to a Decimal .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a Decimal.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(ushort) Method

public static decimal ToDecimal(ushort value);

Summary

Converts a UInt16 to a Decimal .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a Decimal.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(short) Method

public static decimal ToDecimal(short value);

Summary

Converts a Int16 to a Decimal .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a Decimal.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(byte) Method

public static decimal ToDecimal(byte value);

Summary

Converts a Byte to a Decimal .

Parameters

value
The Byte value to be converted.

Return Value

value as a Decimal.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDecimal(sbyte) Method

public static decimal ToDecimal(sbyte value);

Summary

Converts a SByte to a Decimal .

Parameters

value
The SByte value to be converted.

Return Value

value as a Decimal.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(double) Method

public static double ToDouble(double value);

Summary

Converts a Double to a Double .

Parameters

value
The Double value to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(float) Method

public static double ToDouble(float value);

Summary

Converts a Single to a Double .

Parameters

value
The Single value to be converted.

Return Value

value as a Double.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(ulong) Method

public static double ToDouble(ulong value);

Summary

Converts a UInt64 to a Double .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a Double.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDouble(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(long) Method

public static double ToDouble(long value);

Summary

Converts a Int64 to a Double .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a Double.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(uint) Method

public static double ToDouble(uint value);

Summary

Converts a UInt32 to a Double .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a Double.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDouble(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(int) Method

public static double ToDouble(int value);

Summary

Converts a Int32 to a Double .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a Double.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(ushort) Method

public static double ToDouble(ushort value);

Summary

Converts a UInt16 to a Double .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a Double.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDouble(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(short) Method

public static double ToDouble(short value);

Summary

Converts a Int16 to a Double .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a Double.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(byte) Method

public static double ToDouble(byte value);

Summary

Converts a Byte to a Double .

Parameters

value
The Byte value to be converted.

Return Value

value as a Double.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(sbyte) Method

public static double ToDouble(sbyte value);

Summary

Converts a SByte to a Double .

Parameters

value
The SByte value to be converted.

Return Value

value as a Double.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDouble(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(bool) Method

public static double ToDouble(bool value);

Summary

Converts a Boolean to a Double .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(System.Decimal) Method

public static double ToDouble(decimal value);

Summary

Converts a Decimal to a Double .

Parameters

value
The Decimal value to be converted.

Return Value

value as a Double. value is rounded using banker's rounding.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(System.String) Method

public static double ToDouble(string value);

Summary

Converts a String to a Double .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowThousands style.

Return Value

value as a Double.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Double.MaxValue or less than System.Double.MinValue.

Description

This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToDouble(System.String, System.IFormatProvider) Method

public static double ToDouble(string value, IFormatProvider provider);

Summary

Converts a String to a Double .

Parameters

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.

Return Value

value as a Double.

Exceptions

Exception TypeCondition
ArgumentExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Double.MaxValue or less than System.Double.MinValue.

Description

This method parses 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 parsed using the formatting information of the current system culture.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt16(System.Decimal) Method

public static short ToInt16(decimal value);

Summary

Converts a Decimal to a Int16 .

Parameters

value
The Decimal value to be converted.

Return Value

value as a 16-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int16.MaxValue or less than System.Int16.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt16(System.String) Method

public static short ToInt16(string value);

Summary

Converts a String to a Int16 .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.

Return Value

value as a 16-bit signed integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Int16.MaxValue or less than System.Int16.MinValue.

Description

This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToInt16(System.String, System.IFormatProvider) Method

public static short ToInt16(string value, IFormatProvider provider);

Summary

Converts a String to a Int16 .

Parameters

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.

Return Value

value as a 16-bit signed integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Int16.MaxValue or less than System.Int16.MinValue .

Description

This method parses 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 parsed using the formatting information of the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToInt16(double) Method

public static short ToInt16(double value);

Summary

Converts a Double to a Int16 .

Parameters

value
The Double value to be converted.

Return Value

value as a 16-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int16.MaxValue or less than System.Int16.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt16(float) Method

public static short ToInt16(float value);

Summary

Converts a Single to a Int16 .

Parameters

value
The Single value to be converted.

Return Value

value as a 16-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int16.MaxValue or less than System.Int16.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt16(ulong) Method

public static short ToInt16(ulong value);

Summary

Converts a UInt64 to a Int16 .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a 16-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int16.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt16(long) Method

public static short ToInt16(long value);

Summary

Converts a Int64 to a Int16.

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a 16-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int16.MaxValue or less than System.Int16.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToInt16(short) Method

public static short ToInt16(short value);

Summary

Converts a Int16 to a Int16 .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

See Also

System.Convert Class, System Namespace

Convert.ToInt16(uint) Method

public static short ToInt16(uint value);

Summary

Converts a UInt32 to a Int16 .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a 16-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int16.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt16(int) Method

public static short ToInt16(int value);

Summary

Converts a Int32 to a Int16 .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a 16-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int16.MaxValue or less than System.Int16.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToInt16(ushort) Method

public static short ToInt16(ushort value);

Summary

Converts a UInt16 to a Int16 .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a 16-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int16.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt16(byte) Method

public static short ToInt16(byte value);

Summary

Converts a Byte to a Int16 .

Parameters

value
The Byte value to be converted.

Return Value

value as a 16-bit signed integer.

See Also

System.Convert Class, System Namespace

Convert.ToInt16(sbyte) Method

public static short ToInt16(sbyte value);

Summary

Converts a SByte to a Int16 .

Parameters

value
The SByte value to be converted.

Return Value

value as a 16-bit signed integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt16(char) Method

public static short ToInt16(char value);

Summary

Converts a Char to a Int16 .

Parameters

value
The Char to be converted interpreted as an unsigned value.

Return Value

value as a 16-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionThe numeric value of value is greater than System.Int16.MaxValue.

See Also

System.Convert Class, System Namespace

Convert.ToInt16(bool) Method

public static short ToInt16(bool value);

Summary

Converts a Boolean to a Int16 .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

See Also

System.Convert Class, System Namespace

Convert.ToInt32(bool) Method

public static int ToInt32(bool value);

Summary

Converts a Boolean to a Int32 .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

See Also

System.Convert Class, System Namespace

Convert.ToInt32(System.String, System.IFormatProvider) Method

public static int ToInt32(string value, IFormatProvider provider);

Summary

Converts a String to a Int32 .

Parameters

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.

Return Value

value as a 32-bit signed integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Int32.MaxValue or less than System.Int32.MinValue .

Description

This method parses 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 parsed using the formatting information of the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToInt32(System.String) Method

public static int ToInt32(string value);

Summary

Converts a String to a Int32 .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.

Return Value

value as a 32-bit signed integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Int32.MaxValue or less than System.Int32.MinValue.

Description

This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToInt32(System.Decimal) Method

public static int ToInt32(decimal value);

Summary

Converts a Decimal to a Int32 .

Parameters

value
The Decimal value to be converted.

Return Value

value as a 32-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int32.MaxValue or less than System.Int32.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt32(double) Method

public static int ToInt32(double value);

Summary

Converts a Double to a Int32 .

Parameters

value
The Double value to be converted.

Return Value

value as a 32-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int32.MaxValue or less than System.Int32.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt32(float) Method

public static int ToInt32(float value);

Summary

Converts a Single to a Int32 .

Parameters

value
The Single value to be converted.

Return Value

value as a 32-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int32.MaxValue or less than System.Int32.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt32(ulong) Method

public static int ToInt32(ulong value);

Summary

Converts a UInt64 to a Int32 .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a 32-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int32.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt32(long) Method

public static int ToInt32(long value);

Summary

Converts a Int64 to a Int32 .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a 32-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int32.MaxValue or less than System.Int32.MinValue.

See Also

System.Convert Class, System Namespace

Convert.ToInt32(int) Method

public static int ToInt32(int value);

Summary

Converts a Int32 to a Int32 .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

See Also

System.Convert Class, System Namespace

Convert.ToInt32(uint) Method

public static int ToInt32(uint value);

Summary

Converts a UInt32 to a Int32 .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a 32-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int32.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt32(ushort) Method

public static int ToInt32(ushort value);

Summary

Converts a UInt16 to a Int32 .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a 32-bit signed integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt32(short) Method

public static int ToInt32(short value);

Summary

Converts a Int16 to a Int32 .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a 32-bit signed integer.

See Also

System.Convert Class, System Namespace

Convert.ToInt32(byte) Method

public static int ToInt32(byte value);

Summary

Converts a Byte to a Int32 .

Parameters

value
The Byte value to be converted.

Return Value

value as a 32-bit signed integer.

See Also

System.Convert Class, System Namespace

Convert.ToInt32(sbyte) Method

public static int ToInt32(sbyte value);

Summary

Converts a SByte to a Int32 .

Parameters

value
The SByte value to be converted.

Return Value

value as a 32-bit signed integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt32(char) Method

public static int ToInt32(char value);

Summary

Converts a Char to a Int32 .

Parameters

value
The Char to be converted interpreted as an unsigned value.

Return Value

value as a 32-bit signed integer.

See Also

System.Convert Class, System Namespace

Convert.ToInt64(char) Method

public static long ToInt64(char value);

Summary

Converts a Char to a Int64 .

Parameters

value
The Char to be converted interpreted as an unsigned value.

Return Value

value as a 64-bit signed integer.

See Also

System.Convert Class, System Namespace

Convert.ToInt64(bool) Method

public static long ToInt64(bool value);

Summary

Converts a Boolean to a Int64 .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

See Also

System.Convert Class, System Namespace

Convert.ToInt64(sbyte) Method

public static long ToInt64(sbyte value);

Summary

Converts a SByte to a Int64 .

Parameters

value
The SByte value to be converted.

Return Value

value as a 64-bit signed integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt64(byte) Method

public static long ToInt64(byte value);

Summary

Converts a Byte to a Int64 .

Parameters

value
The Byte value to be converted.

Return Value

value as a 64-bit signed integer.

See Also

System.Convert Class, System Namespace

Convert.ToInt64(short) Method

public static long ToInt64(short value);

Summary

Converts a Int16 to a Int64 .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a 64-bit signed integer.

See Also

System.Convert Class, System Namespace

Convert.ToInt64(ushort) Method

public static long ToInt64(ushort value);

Summary

Converts a UInt16 to a Int64 .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a 64-bit signed integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt64(int) Method

public static long ToInt64(int value);

Summary

Converts a Int32 to a Int64 .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a 64-bit signed integer.

See Also

System.Convert Class, System Namespace

Convert.ToInt64(uint) Method

public static long ToInt64(uint value);

Summary

Converts a UInt32 to a Int64 .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a 64-bit signed integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt64(ulong) Method

public static long ToInt64(ulong value);

Summary

Converts a UInt64 to a Int64 .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a 64-bit signed integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int64.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToInt64(long) Method

public static long ToInt64(long value);

Summary

Converts a Int64 to a Int64 .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

See Also

System.Convert Class, System Namespace

Convert.ToInt64(float) Method

public static long ToInt64(float value);

Summary

Converts a Single to a Int64 .

Parameters

value
The Single value to be converted.

Return Value

value as a 64-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt64(double) Method

public static long ToInt64(double value);

Summary

Converts a Double to a Int64 .

Parameters

value
The Double value to be converted.

Return Value

value as a 64-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt64(System.Decimal) Method

public static long ToInt64(decimal value);

Summary

Converts a Decimal to a Int64 .

Parameters

value
The Decimal value to be converted.

Return Value

value as a 64-bit signed integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

Description

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.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToInt64(System.String) Method

public static long ToInt64(string value);

Summary

Converts a String to a Int64 .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.

Return Value

value as a 64-bit signed integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

Description

This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToInt64(System.String, System.IFormatProvider) Method

public static long ToInt64(string value, IFormatProvider provider);

Summary

Converts a String to a Int64 .

Parameters

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.

Return Value

value as a 64-bit signed integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Int64.MaxValue or less than System.Int64.MinValue.

Description

This method parses 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 parsed using the formatting information of the current system culture.

See Also

System.Convert Class, System Namespace

Convert.ToSByte(bool) Method

public static sbyte ToSByte(bool value);

Summary

Converts a Boolean to a SByte .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Boolean).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(sbyte) Method

public static sbyte ToSByte(sbyte value);

Summary

Converts a SByte to a SByte .

Parameters

value
The SByte value to be converted.

Return Value

value is returned unchanged.

Description

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.]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(char) Method

public static sbyte ToSByte(char value);

Summary

Converts a Char to a SByte .

Parameters

value
The Char to be converted interpreted as an unsigned value.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
OverflowExceptionThe numeric value of value is greater than System.SByte.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Char).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(byte) Method

public static sbyte ToSByte(byte value);

Summary

Converts a Byte to a SByte .

Parameters

value
The Byte value to be converted.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Byte).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(short) Method

public static sbyte ToSByte(short value);

Summary

Converts a Int16 to a SByte .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue or less than System.SByte.MinValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(ushort) Method

public static sbyte ToSByte(ushort value);

Summary

Converts a UInt16 to a SByte .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(int) Method

public static sbyte ToSByte(int value);

Summary

Converts a Int32 to a SByte .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue or less than System.SByte.MinValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(uint) Method

public static sbyte ToSByte(uint value);

Summary

Converts a UInt32 to a SByte .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(long) Method

public static sbyte ToSByte(long value);

Summary

Converts a Int64 to a SByte .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue or less than System.SByte.MinValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(ulong) Method

public static sbyte ToSByte(ulong value);

Summary

Converts a UInt64 to a SByte .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt16(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(float) Method

public static sbyte ToSByte(float value);

Summary

Converts a Single to a SByte .

Parameters

value
The Single value to be converted.

Return Value

value as a SByte , rounded to the nearest integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue or less than System.SByte.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSByte(double) Method

public static sbyte ToSByte(double value);

Summary

Converts a Double to a SByte .

Parameters

value
The Double value to be converted.

Return Value

value as a SByte , rounded to the nearest integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue or less than System.SByte.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSByte(System.Decimal) Method

public static sbyte ToSByte(decimal value);

Summary

Converts a Decimal to a SByte .

Parameters

value
The Decimal value to be converted.

Return Value

value as a SByte , rounded to the nearest integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.SByte.MaxValue or less than System.SByte.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSByte(System.String) Method

public static sbyte ToSByte(string value);

Summary

Converts a String representation of a number to a SByte .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.

Return Value

value as a SByte.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value in the specified format.
OverflowExceptionThe numeric value of value is greater than System.SByte.MaxValue or less than System.SByte.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSByte(System.String, System.IFormatProvider) Method

public static sbyte ToSByte(string value, IFormatProvider provider);

Summary

Converts a String to a SByte .

Parameters

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.

Return Value

value as a SByte.

Description

This method parses 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 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 ).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToSingle(System.String, System.IFormatProvider) Method

public static float ToSingle(string value, IFormatProvider provider);

Summary

Converts a String to a Single .

Parameters

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.

Return Value

value as a Single.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Single.MaxValue or less than System.Single.MinValue.

Description

This method parses 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 parsed using the formatting information of the current system culture.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(System.String) Method

public static float ToSingle(string value);

Summary

Converts a String to a Single .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowThousands style.

Return Value

value as a Single.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.Single.MaxValue or less than System.Single.MinValue.

Description

This method parses value using the information in a NumberFormatInfo instance initialized for the current system culture.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(System.Decimal) Method

public static float ToSingle(decimal value);

Summary

Converts a Decimal to a Single .

Parameters

value
The Decimal value to be converted.

Return Value

value as a Single. value is rounded using banker's rounding.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(double) Method

public static float ToSingle(double value);

Summary

Converts a Double to a Single .

Parameters

value
The Double value to be converted.

Return Value

value as a Single.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.Single.MaxValue or less than System.Single.MinValue.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(float) Method

public static float ToSingle(float value);

Summary

Converts a Single to a Single .

Parameters

value
The Single value to be converted.

Return Value

value as a Single .

Description

[Note: This method is provided for completeness.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(ulong) Method

public static float ToSingle(ulong value);

Summary

Converts a UInt64 to a Single .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a Single.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToSingle(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(long) Method

public static float ToSingle(long value);

Summary

Converts a Int64 to a Single .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a Single.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(uint) Method

public static float ToSingle(uint value);

Summary

Converts a UInt32 to a Single .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a Single.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToSingle(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(int) Method

public static float ToSingle(int value);

Summary

Converts a Int32 to a Single .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a Single.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(ushort) Method

public static float ToSingle(ushort value);

Summary

Converts a UInt16 to a Single .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a Single.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToSingle(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(short) Method

public static float ToSingle(short value);

Summary

Converts a Int16 to a Single .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a Single.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(byte) Method

public static float ToSingle(byte value);

Summary

Converts a Byte to a Single .

Parameters

value
The Byte value to be converted.

Return Value

value as a Single.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(sbyte) Method

public static float ToSingle(sbyte value);

Summary

Converts a SByte to a Single .

Parameters

value
The SByte value to be converted.

Return Value

value as a Single.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToSingle(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToSingle(bool) Method

public static float ToSingle(bool value);

Summary

Converts a Boolean to a Single .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToString(uint, System.IFormatProvider) Method

public static string ToString(uint value, IFormatProvider provider);

Summary

Converts a UInt32 to a String .

Parameters

value
The 32-bit unsigned integer value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToString(long) Method

public static string ToString(long value);

Summary

Converts a Int64 to a String .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

[Note: See System.Int64.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(long, System.IFormatProvider) Method

public static string ToString(long value, IFormatProvider provider);

Summary

Converts a Int64 to a String .

Parameters

value
The 64-bit signed integer value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.Int64.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(ulong) Method

public static string ToString(ulong value);

Summary

Converts a UInt64 to a String .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Decimal).

[Note: See System.UInt64.ToString.]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToString(ulong, System.IFormatProvider) Method

public static string ToString(ulong value, IFormatProvider provider);

Summary

Converts a UInt64 to a String .

Parameters

value
The 64-bit unsigned integer value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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 .]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToString(float) Method

public static string ToString(float value);

Summary

Converts a Single to a String .

Parameters

value
The Single value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

[Note: See System.Single.ToString.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToString(float, System.IFormatProvider) Method

public static string ToString(float value, IFormatProvider provider);

Summary

Converts a Single to a String .

Parameters

value
The Single value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.Single.ToString.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToString(double) Method

public static string ToString(double value);

Summary

Converts a Double to a String .

Parameters

value
The Double value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

[Note: See System.Double.ToString.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToString(double, System.IFormatProvider) Method

public static string ToString(double value, IFormatProvider provider);

Summary

Converts a Double to a String .

Parameters

value
The Double value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.Double.ToString.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToString(System.Decimal) Method

public static string ToString(decimal value);

Summary

Converts a Decimal to a String .

Parameters

value
The Decimal value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

[Note: See System.Decimal.ToString.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToString(System.Decimal, System.IFormatProvider) Method

public static string ToString(decimal value, IFormatProvider provider);

Summary

Converts a Decimal to a String .

Parameters

value
The Decimal value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.Decimal.ToString.]

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToString(System.DateTime) Method

public static string ToString(DateTime value);

Summary

Converts a DateTime value to a String .

Parameters

value
The DateTime value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

[Note: See System.DateTime.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(System.DateTime, System.IFormatProvider) Method

public static string ToString(DateTime value, IFormatProvider provider);

Summary

Converts a DateTime value to a String .

Parameters

value
The DateTime value to be converted.
provider
A IFormatProvider that supplies a DateTimeFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

This method converts value using the information in the DateTimeFormatInfo instance supplied by provider. If provider is null 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.]

See Also

System.Convert Class, System Namespace

Convert.ToString(uint) Method

public static string ToString(uint value);

Summary

Converts a UInt32 to a String .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int64).

[Note: See System.UInt32.ToString.]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToString(int, System.IFormatProvider) Method

public static string ToString(int value, IFormatProvider provider);

Summary

Converts a Int32 to a String .

Parameters

value
The 32-bit signed integer value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.Int32.ToString .]

See Also

System.Convert Class, System Namespace

Convert.ToString(int) Method

public static string ToString(int value);

Summary

Converts a Int32 to a String .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

[Note: See System.Int32.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(ushort, System.IFormatProvider) Method

public static string ToString(ushort value, IFormatProvider provider);

Summary

Converts a UInt16 to a String .

Parameters

value
The 16-bit unsigned integer value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToString(ushort) Method

public static string ToString(ushort value);

Summary

Converts a UInt16 to a String .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int32).

[Note: See System.UInt16.ToString.]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToString(short, System.IFormatProvider) Method

public static string ToString(short value, IFormatProvider provider);

Summary

Converts a Int16 to a String .

Parameters

value
The 16-bit signed integer value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.Int16.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(short) Method

public static string ToString(short value);

Summary

Converts a Int16 to a String .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

[Note: See System.Int16.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(byte, System.IFormatProvider) Method

public static string ToString(byte value, IFormatProvider provider);

Summary

Converts a Byte to a String .

Parameters

value
The Byte value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.Byte.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(byte) Method

public static string ToString(byte value);

Summary

Converts a Byte to a String .

Parameters

value
The Byte value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

[Note: See System.Byte.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(sbyte, System.IFormatProvider) Method

public static string ToString(sbyte value, IFormatProvider provider);

Summary

Converts a SByte to a String .

Parameters

value
The SByte value to be converted.
provider
A IFormatProvider that supplies a NumberFormatInfo containing culture-specific formatting information.

Return Value

Returns the value returned by value.ToString(provider).

Description

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.]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToString(sbyte) Method

public static string ToString(sbyte value);

Summary

Converts a SByte to a String .

Parameters

value
The SByte value to be converted.

Return Value

Returns the value returned by value.ToString().

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToString(System.Object)(Int16).

[Note: See System.SByte.ToString.]

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToString(char) Method

public static string ToString(char value);

Summary

Converts a Char to a String .

Parameters

value
The Char to be converted.

Return Value

value as a String.

See Also

System.Convert Class, System Namespace

Convert.ToString(bool) Method

public static string ToString(bool value);

Summary

Converts a Boolean to a String .

Parameters

value
The Boolean value to be converted.

Return Value

Returns the value returned by value .ToString().

Description

[Note: See System.Boolean.ToString.]

See Also

System.Convert Class, System Namespace

Convert.ToString(System.String) Method

public static string ToString(string value);

Summary

Returns the specified string.

Parameters

value
A String.

Return Value

value is returned unchanged.

Description

[Note: This method is provided for completeness.]

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(System.String, System.IFormatProvider) Method

public static ushort ToUInt16(string value, IFormatProvider provider);

Summary

Converts a String to a UInt16 .

Parameters

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.

Return Value

value as a 16-bit unsigned integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.

Description

This method parses 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 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).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(System.String) Method

public static ushort ToUInt16(string value);

Summary

Converts a String to a UInt16 .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.

Return Value

value as a 16-bit unsigned integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(System.Decimal) Method

public static ushort ToUInt16(decimal value);

Summary

Converts a Decimal to a UInt16 .

Parameters

value
The Decimal value to be converted.

Return Value

value as a 16-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(double) Method

public static ushort ToUInt16(double value);

Summary

Converts a Double to a UInt16 .

Parameters

value
The Double value to be converted.

Return Value

value as a 16-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(float) Method

public static ushort ToUInt16(float value);

Summary

Converts a Single to a UInt16 .

Parameters

value
The Single value to be converted.

Return Value

value as a 16-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(ulong) Method

public static ushort ToUInt16(ulong value);

Summary

Converts a UInt64 to a UInt16 .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a 16-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt16.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(long) Method

public static ushort ToUInt16(long value);

Summary

Converts a Int64 to a UInt16 .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a 16-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(uint) Method

public static ushort ToUInt16(uint value);

Summary

Converts a UInt32 to a UInt16 .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a 16-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt16.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(ushort) Method

public static ushort ToUInt16(ushort value);

Summary

Converts a UInt16 to a UInt16 .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value is returned unchanged.

Description

[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).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(int) Method

public static ushort ToUInt16(int value);

Summary

Converts a Int32 to a UInt16 .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a 16-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt16.MaxValue or less than System.UInt16.MinValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(short) Method

public static ushort ToUInt16(short value);

Summary

Converts a Int16 to a UInt16 .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a 16-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt16.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(byte) Method

public static ushort ToUInt16(byte value);

Summary

Converts a Byte to a UInt16 .

Parameters

value
The Byte value to be converted.

Return Value

value as a 16-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Byte).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(sbyte) Method

public static ushort ToUInt16(sbyte value);

Summary

Converts a SByte to a UInt16 .

Parameters

value
The SByte value to be converted.

Return Value

value as a 16-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt16.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(char) Method

public static ushort ToUInt16(char value);

Summary

Converts a Char to a UInt16 .

Parameters

value
The Char to be converted interpreted as an unsigned value.

Return Value

value as a 16-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Char).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt16(bool) Method

public static ushort ToUInt16(bool value);

Summary

Converts a Boolean to a UInt16 .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt32(System.Object)(Boolean).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(bool) Method

public static uint ToUInt32(bool value);

Summary

Converts a Boolean to a UInt32 .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Boolean).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(char) Method

public static uint ToUInt32(char value);

Summary

Converts a Char to a UInt32 .

Parameters

value
The Char to be converted interpreted as an unsigned value.

Return Value

value as a 32-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Char).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(sbyte) Method

public static uint ToUInt32(sbyte value);

Summary

Converts a SByte to a UInt32 .

Parameters

value
The SByte value to be converted.

Return Value

value as a 32-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt32.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(byte) Method

public static uint ToUInt32(byte value);

Summary

Converts a Byte to a UInt32 .

Parameters

value
The Byte value to be converted.

Return Value

value as a 32-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Byte).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(short) Method

public static uint ToUInt32(short value);

Summary

Converts a Int16 to a UInt32 .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a 32-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt32.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(ushort) Method

public static uint ToUInt32(ushort value);

Summary

Converts a UInt16 to a UInt32 .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a 32-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(int) Method

public static uint ToUInt32(int value);

Summary

Converts a Int32 to a UInt32 .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a 32-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt32.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(uint) Method

public static uint ToUInt32(uint value);

Summary

Converts a UInt32 to a UInt32 .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value is returned unchanged.

Description

[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).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(long) Method

public static uint ToUInt32(long value);

Summary

Converts a Int64 to a UInt32 .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a 32-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(ulong) Method

public static uint ToUInt32(ulong value);

Summary

Converts a UInt64 to a UInt32 .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value as a 32-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt32.MaxValue.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToInt64(System.Object)(Decimal).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(float) Method

public static uint ToUInt32(float value);

Summary

Converts a Single to a UInt32 .

Parameters

value
The Single value to be converted.

Return Value

value as a 32-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(double) Method

public static uint ToUInt32(double value);

Summary

Converts a Double to a UInt32 .

Parameters

value
The Double value to be converted.

Return Value

value as a 32-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(System.Decimal) Method

public static uint ToUInt32(decimal value);

Summary

Converts a Decimal to a UInt32 .

Parameters

value
The Decimal value to be converted.

Return Value

value as a 32-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(System.String) Method

public static uint ToUInt32(string value);

Summary

Converts a String to a UInt32 .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.

Return Value

value as a 32-bit unsigned integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt32(System.String, System.IFormatProvider) Method

public static uint ToUInt32(string value, IFormatProvider provider);

Summary

Converts a String to a UInt32 .

Parameters

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.

Return Value

value as an 32-bit unsigned integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.UInt32.MaxValue or less than System.UInt32.MinValue.

Description

This method parses 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 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 ).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(System.String, System.IFormatProvider) Method

public static ulong ToUInt64(string value, IFormatProvider provider);

Summary

Converts a String to a UInt64 .

Parameters

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.

Return Value

value as a 64-bit unsigned integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is a null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.

Description

This method parses 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 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 ).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(System.String) Method

public static ulong ToUInt64(string value);

Summary

Converts a String to a UInt64 .

Parameters

value
The String to be converted. The string is in the System.Globalization.NumberStyles.Integer style.

Return Value

value as a 64-bit unsigned integer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionvalue is null reference.
FormatExceptionvalue cannot be converted to a numeric value.
OverflowExceptionThe numeric value of value is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(System.Decimal) Method

public static ulong ToUInt64(decimal value);

Summary

Converts a Decimal to a UInt64 .

Parameters

value
The Decimal value to be converted.

Return Value

value as a 64-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(double) Method

public static ulong ToUInt64(double value);

Summary

Converts a Double to a UInt64 .

Parameters

value
The Double value to be converted.

Return Value

value as a 64-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(float) Method

public static ulong ToUInt64(float value);

Summary

Converts a Single to a UInt64 .

Parameters

value
The Single value to be converted.

Return Value

value as a 64-bit unsigned integer. value is rounded prior to conversion.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is greater than System.UInt64.MaxValue or less than System.UInt64.MinValue.

Description

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).

Attributes

CLSCompliantAttribute(false)

Library

ExtendedNumerics

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(ulong) Method

public static ulong ToUInt64(ulong value);

Summary

Converts a UInt64 to a UInt64 .

Parameters

value
The 64-bit unsigned integer value to be converted.

Return Value

value is returned unchanged.

Description

[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).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(long) Method

public static ulong ToUInt64(long value);

Summary

Converts a Int64 to a UInt64 .

Parameters

value
The 64-bit signed integer value to be converted.

Return Value

value as a 64-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt64.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(uint) Method

public static ulong ToUInt64(uint value);

Summary

Converts a UInt32 to a UInt64 .

Parameters

value
The 32-bit unsigned integer value to be converted.

Return Value

value as a 64-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int64).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(int) Method

public static ulong ToUInt64(int value);

Summary

Converts a Int32 to a UInt64 .

Parameters

value
The 32-bit signed integer value to be converted.

Return Value

value as a 64-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt64.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(ushort) Method

public static ulong ToUInt64(ushort value);

Summary

Converts a UInt16 to a UInt64 .

Parameters

value
The 16-bit unsigned integer value to be converted.

Return Value

value as a 64-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int32).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(short) Method

public static ulong ToUInt64(short value);

Summary

Converts a Int16 to a UInt64 .

Parameters

value
The 16-bit signed integer value to be converted.

Return Value

value as a 64-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt64.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(byte) Method

public static ulong ToUInt64(byte value);

Summary

Converts a Byte to a UInt64 .

Parameters

value
The Byte value to be converted.

Return Value

value as a 64-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Byte).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(sbyte) Method

public static ulong ToUInt64(sbyte value);

Summary

Converts a SByte to a UInt64 .

Parameters

value
The SByte value to be converted.

Return Value

value as a 64-bit unsigned integer.

Exceptions

Exception TypeCondition
OverflowExceptionvalue is less than System.UInt64.MinValue .

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Int16).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(char) Method

public static ulong ToUInt64(char value);

Summary

Converts a Char to a UInt64 .

Parameters

value
The Char to be converted interpreted as an unsigned value.

Return Value

value as a 64-bit unsigned integer.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Char).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace

Convert.ToUInt64(bool) Method

public static ulong ToUInt64(bool value);

Summary

Converts a Boolean to a UInt64 .

Parameters

value
The Boolean value to be converted.

Return Value

If value is true returns 1; if value is false returns 0.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.Convert.ToDecimal(System.Object)(Boolean).

Attributes

CLSCompliantAttribute(false)

See Also

System.Convert Class, System Namespace