Convert.ToDouble Method (Int32)

 

Converts the value of the specified 32-bit signed integer to an equivalent double-precision floating-point number.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Function ToDouble (
	value As Integer
) As Double

Parameters

value
Type: System.Int32

The 32-bit signed integer to convert.

Return Value

Type: System.Double

A double-precision floating-point number that is equivalent to value.

The following example converts an Int32 value to a Double value.

Public Sub ConvertDoubleInt(ByVal doubleVal As Double)

    Dim intVal As Integer = 0
    ' Double to Integer conversion can overflow.
    Try
        intVal = System.Convert.ToInt32(doubleVal)
        System.Console.WriteLine("{0} as an Integer is: {1}", _
                                  doubleVal, intVal)
    Catch exception As System.OverflowException
        System.Console.WriteLine( _
            "Overflow in Double-to-Byte conversion.")
    End Try

    ' Integer to Double conversion cannot overflow.
    doubleVal = System.Convert.ToDouble(intVal)
    System.Console.WriteLine("{0} as a Double is: {1}", _
                              intVal, doubleVal)
End Sub

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: