Main Content

Create Delegates from .NET Object Methods

The following C# class defines the methodsAddEggsandAddFlour, which have signatures matching thedelIntegerdelegate:

C# Recipe Source File

Build theRecipeassembly, and then load it and create a delegatemyFuncusingAddEggsas 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

Related Examples

More About