ClearScript Library
ClearScript Library
ClearScript Library Reference
Microsoft.ClearScript
HostFunctions Class
HostFunctions Methods
asType<T> Method
cast<T> Method
del<T> Method
flags<T> Method
func Method
getElement Method
getProperty Method
isNull Method
isType<T> Method
isTypeObj Method
newArr Method
newObj Method
newVar<T> Method
proc Method
removeElement Method
removeProperty Method
setElement Method
setProperty Method
toByte Method
toChar Method
toDecimal Method
toDouble Method
toInt16 Method
toInt32 Method
toInt64 Method
toSByte Method
toSingle Method
toStaticType Method
toUInt16 Method
toUInt32 Method
toUInt64 Method
tryCatch Method
typeOf Method

# HostFunctionsdel T Method

Creates a delegate that invokes a script function.
Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.5.0
Syntax
C#
VB
C++
F#
Copy

    public T del<T>(
    	Object scriptFunc
    )

    Public Function del(Of T) (
    	scriptFunc As Object
    ) As T

    public:
    generic<typename T>
    T del(
    	Object^ scriptFunc
    )

    member del :
            scriptFunc : Object -> 'T

#### Parameters

scriptFunc Object
  The script function for which to create a delegate.

#### Type Parameters

T
  The type of delegate to create.

#### Return Value

T
A new delegate that invokes the specified script function.
Remarks
If the delegate signature includes parameters passed by reference, the corresponding arguments to the script function will be host variables. The script function can set the value of an output argument by assigning the corresponding host variable's value property.
Example
The following code demonstrates delegating a callback to a script function. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
JavaScript
Copy

    // create and populate an array of integers
    var EnumerableT = host.type("System.Linq.Enumerable", "System.Core");
    var array = EnumerableT.Range(1, 5).ToArray();
    // import the callback type required to call Array.ForEach
    var Int32T = host.type("System.Int32");
    var CallbackT = host.type("System.Action", Int32T);
    // use Array.ForEach to calculate a sum
    var sum = 0;
    var ArrayT = host.type("System.Array");
    ArrayT.ForEach(array, host.del(CallbackT, function (value) { sum += value; }));

See Also

#### Reference

HostFunctions Class
Microsoft.ClearScript Namespace
type(String, String, Object)
type(String, Object)

Copyright © Microsoft Corporation. All rights reserved.

Send comments on this topic to Microsoft