HostFunctionsnewVarT Method | 
            Creates a host variable of the specified type.
            
Namespace: Microsoft.ClearScriptAssembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.5.0
Syntaxpublic Object newVar<T>(
	T initValue = null
)
Public Function newVar(Of T) ( 
	Optional initValue As T = Nothing
) As Object
public:
generic<typename T>
Object^ newVar(
	T initValue = nullptr
)
member newVar : 
        ?initValue : 'T 
(* Defaults:
        let _initValue = defaultArg initValue null
*)
-> Object Parameters
- initValue  T  (Optional)
 - An optional initial value for the variable.
 
Type Parameters
- T
 - The type of variable to create.
 
Return Value
ObjectA new host variable of the specified type.
Remarks
            A host variable is a strongly typed object that holds a value of the specified type.
            Host variables are useful for passing method arguments by reference. In addition to
            being generally interchangeable with their stored values, host variables support the
            following properties:
            
| Property | Access | Description | 
|---|
| value | read-write | The current value of the host variable. | 
| out | read-only | A reference to the host variable that can be passed as an out argument. | 
| ref | read-only | A reference to the host variable that can be passed as a ref argument. | 
Example
            The following code demonstrates using a host variable to invoke a method with an
            
out parameter.
            It assumes that an instance of 
ExtendedHostFunctions is exposed under
            the name "host"
            (see 
AddHostObject).
            
var StringT = host.type("System.String");
var StringDictT = host.type("System.Collections.Generic.Dictionary", StringT, StringT);
var dict = host.newObj(StringDictT);
dict.Add("foo", "bar");
dict.Add("baz", "qux");
var result = host.newVar(StringT);
var found = dict.TryGetValue("baz", result.out);
See Also