Click or drag to resize

HostFunctionscastT Method

Casts an object to the specified host type.

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.4.5
Syntax
public Object cast<T>(
	Object value
)

Parameters

value  Object
The object to cast to the specified host type.

Type Parameters

T
The host type to which to cast value.

Return Value

Object
The result of the cast.
Remarks
If the cast fails, this function throws an exception.
Example
The following code casts a floating-point value to a 32-bit integer. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
JavaScript
var Int32T = host.type("System.Int32");
var intValue = host.cast(Int32T, 12.5);
See Also