HostFunctionscastT Method |
Casts an object to the specified host type.
Namespace: Microsoft.ClearScriptAssembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.4.5
Syntax public Object cast<T>(
Object value
)
Public Function cast(Of T) (
value As Object
) As Object
public:
generic<typename T>
Object^ cast(
Object^ value
)
member cast :
value : Object -> Object
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
ObjectThe 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).
var Int32T = host.type("System.Int32");
var intValue = host.cast(Int32T, 12.5);
See Also