Main Content
Create Delegates from .NET Object Methods
The following C# class defines the methods AddEggs
and
AddFlour
, which have signatures matching the
delInteger
delegate:
Build the Recipe
assembly, and then load it and create a delegate
myFunc
using AddEggs
as the callback:
NET.addAssembly(dllPath);
NET.addAssembly('c:\work\Recipe.dll');
myRec = Recipe.MyClass;
myFunc = NetDocDelegate.delInteger(@myRec.AddEggs);
myFunc(2)
ans = Add 2 eggs