Click or drag to resize

HostFunctionstoUInt16 Method

Converts the specified value to a strongly typed UInt16 instance.

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.4.5
public Object toUInt16(
	IConvertible value


value  IConvertible
The value to convert.

Return Value

An object that can be passed to a parameter of type UInt16.
This function converts value to UInt16 and packages the result to retain its numeric type across the host-script boundary. It may be useful for passing arguments to UInt16 parameters if the script engine does not support that type natively.
The following code adds an element of type UInt16 to a strongly typed list. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
// import types
var ElementT = host.type("System.UInt16");
var ListT = host.type("System.Collections.Generic.List", ElementT);
// create a list
var list = host.newObj(ListT);
// add a list element
See Also