Main Content

.NET Delegates

In .NET, a delegate is a type that defines a method signature. It lets you pass a function as a parameter. The use of delegates enables .NET applications to make calls into MATLAB® callback functions or class instance methods. For the rules MATLAB uses to define the signature of a callback function or class method, see Reading Method Signatures. For a complete description of delegates and when to use them, consult an outside resource, such as the Microsoft® Developer Network.

There are three steps to using delegates:

  • Declaration — Your .NET application contains the declaration. You cannot declare a delegate in the MATLAB language.

  • Instantiation — In MATLAB, create an instance of the delegate and associate it with a specific MATLAB function or .NET object method.

  • Invocation — Call the function with specified input and output arguments. Use the delegate name in place of the function name.

Related Topics