The. NET language has one more delegate than other object-oriented languages (I'm not sure if Java has this concept, as though I have never seen it ). It's hard to understand, so sort out your ideas.
In general, delegation is a way to convert a function into a variable, so that the function can be assigned a value or superimposed. In PHP, the language itself uses a simple feature to support similar basic methods. If any string variable is followed by parentheses, it can be executed as a function, the system automatically finds the function with the same variable value for execution.
In C #, delegates greatly enhance this application. You can declare a delegate (a common function declaration, modifier plus delegate, and only a function declaration including parameters without function bodies ), then, use the delegate name to declare a specific variable. Now, you can add a function body that is the same as the delegate declaration method. In addition, multiple functions can be added to the same delegate variable. Both static and Instance functions can be used.
When the delegate variable is called by running a function at a certain position, all functions bound to it are executed sequentially. This is the implementation method in which VB. NET and C # bind their functions (methods) to an existing class event (also a function) and are actively called by the other party. In fact, the other class calls its own delegate variable in the middle of a method.