Contenido del Curso
Advanced C# with .NET
Advanced C# with .NET
Delegates
Important Points:
- Delegates are types that can reference methods of a certain kind of signature;
- Delegates allow us to pass methods as arguments;
- The syntax of a creating a new delegate type is as follows:
delegate <return type> <type name> (parameter1, parameter2, …);
; - We can create a variable using a delegate type and assign it a method reference using the following syntax:
DelegateTypeName variableName = methodName;
; - More methods can be added to a delegate instance using the
+=
operator; - Methods can be removed from a delegate instance using the
-+
operator; - In case there are multiple methods in a delegate instance that return a value, the value of the last executed method is returned;
¡Gracias por tus comentarios!