HostFunctionstoSingle Method |
Converts the specified value to a strongly typed
Single instance.
Namespace: Microsoft.ClearScriptAssembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.4.5
Syntax public Object toSingle(
IConvertible value
)
Public Function toSingle (
value As IConvertible
) As Object
public:
Object^ toSingle(
IConvertible^ value
)
member toSingle :
value : IConvertible -> Object
Parameters
- value IConvertible
- The value to convert.
Return Value
ObjectAn object that can be passed to a parameter of type
Single.
Remarks
This function converts
value to
Single and
packages the result to retain its numeric type across the host-script boundary. It may
be useful for passing arguments to
Single parameters if the script
engine does not support that type natively.
Example
The following code adds an element of type
Single to a strongly
typed list.
It assumes that an instance of
ExtendedHostFunctions is exposed under
the name "host"
(see
AddHostObject).
var ElementT = host.type("System.Single");
var ListT = host.type("System.Collections.Generic.List", ElementT);
var list = host.newObj(ListT);
list.Add(host.toSingle(42));
See Also