ClearScript Library
ClearScript Library
ClearScript Library Reference
Microsoft.ClearScript
HostFunctions Class
HostFunctions Methods
asType<T> Method
cast<T> Method
del<T> Method
flags<T> Method
func Method
getElement Method
getProperty Method
isNull Method
isType<T> Method
isTypeObj Method
newArr Method
newObj Method
newVar<T> Method
proc Method
removeElement Method
removeProperty Method
setElement Method
setProperty Method
toByte Method
toChar Method
toDecimal Method
toDouble Method
toInt16 Method
toInt32 Method
toInt64 Method
toSByte Method
toSingle Method
toStaticType Method
toUInt16 Method
toUInt32 Method
toUInt64 Method
tryCatch Method
typeOf Method

# HostFunctionstoDouble Method

Converts the specified value to a strongly typed Double instance.
Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.5.0
Syntax
C#
VB
C++
F#
Copy

    public Object toDouble(
    	IConvertible value
    )

    Public Function toDouble (
    	value As IConvertible
    ) As Object

    public:
    Object^ toDouble(
    	IConvertible^ value
    )

    member toDouble :
            value : IConvertible -> Object

#### Parameters

value IConvertible
  The value to convert.

#### Return Value

Object
An object that can be passed to a parameter of type Double.
Remarks
This function converts value to Double and packages the result to retain its numeric type across the host-script boundary. It may be useful for passing arguments to Double parameters if the script engine does not support that type natively.
Example
The following code adds an element of type Double to a strongly typed list. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
JavaScript
Copy

    // import types
    var ElementT = host.type("System.Double");
    var ListT = host.type("System.Collections.Generic.List", ElementT);
    // create a list
    var list = host.newObj(ListT);
    // add a list element
    list.Add(host.toDouble(42));

See Also

#### Reference

HostFunctions Class
Microsoft.ClearScript Namespace
type(String, Object)

Copyright © Microsoft Corporation. All rights reserved.

Send comments on this topic to Microsoft