Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ToDouble Method (Object, IFormatProvider)

Convert.ToDouble Method (Object, IFormatProvider)

Converts the value of the specified object to an double-precision floating-point number, using the specified culture-specific formatting information.

Namespace:  System
Assemblies:   System.Runtime.Extensions (in System.Runtime.Extensions.dll)
  mscorlib (in mscorlib.dll)

static member ToDouble : 
        value:Object * 
        provider:IFormatProvider -> float

Parameters

value
Type: System.Object

An object that implements the IConvertible interface.

provider
Type: System.IFormatProvider

An object that supplies culture-specific formatting information.

Return Value

Type: System.Double
A double-precision floating-point number that is equivalent to value, or zero if value is a null reference (Nothing in Visual Basic).

ExceptionCondition
FormatException

value is not in an appropriate format for a Double type.

InvalidCastException

value does not implement the IConvertible interface.

OverflowException

value represents a number that is less than Double.MinValue or greater than Double.MaxValue.

The return value is the result of invoking the IConvertible.ToDouble method of the underlying type of value.

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

The base types ignore provider; however, the parameter may be used if value is a user-defined type that implements the IConvertible interface.

The following example defines a class that implements IConvertible and a class that implements IFormatProvider. Objects of the class that implements IConvertible hold an array of Double values. An object of each class is passed to the ToDouble method. This method returns an average of the array of Double values, using the object that implements IFormatProvider to determine how to calculate the average.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft