Click or drag to resize

HostFunctionsnewObjT(Object) Method

Creates a host object of the specified type. This version is invoked if the specified type can be used as a type argument.

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.3.5
public T newObj<T>(
	params Object[] args


args  Object
Optional constructor arguments.

Type Parameters

The type of object to create.

Return Value

A new host object of the specified type.

This function is provided for script languages that do not support external instantiation. It is overloaded with newObj(Object, Object) and selected at runtime if T can be used as a type argument.

For information about the mapping between host members and script-callable properties and methods, see AddHostObject.

The following code imports the Random class, creates an instance using the Random(Int32) constructor, and calls the NextDouble method. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
var RandomT = host.type("System.Random");
var random = host.newObj(RandomT, 100);
var value = random.NextDouble();
See Also