Create Delegate Instances Bound to .NET Methods
For a C# delegate defined as:
namespace MyNamespace
{
public delegate void MyDelegate();
}
MATLAB® creates the following constructor signature.
| Return Type | Name | Arguments |
|---|---|---|
MyNamespace.MyDelegate obj | MyDelegate | (target, |
The argument target is one of the following:
An instance of the invocation target object when binding to the instance method
A string with fully qualified .NET class name when binding to a static method
methodName is a string specifying the callback method name.
Example — Create a Delegate Instance Associated with a .NET Object Instance Method
For the following C# delegate and class definition:
namespace MyNamespace
{
public delegate void MyDelegate();
public class MyClass
{
public void MyMethod(){}
}
}To instantiate the delegate in MATLAB, type:
target = MyNamespace.MyClass();
delegate = MyNamespace.MyDelegate(target,'MyMethod');Example — Create a Delegate Instance Associated with a Static .NET Method
For the following C# delegate and class definition:
namespace MyNamespace
{
public delegate void MyDelegate();
public class MyClass
{
public static void MyStaticMethod(){}
}
}To instantiate the delegate in MATLAB, type:
delegate = MyNamespace.MyDelegate('MyNamespace.MyClass','MyStaticMethod');