SHOW:
|
|
- or go back to the newest paste.
| 1 | A delegate in C# is similar to a function pointer in C. | |
| 2 | ||
| 3 | And using a delegate allows a programmer to encapsulate a reference to a method inside a delegate. | |
| 4 | ||
| 5 | The delegate object can then be passed to code which can call the reference without knowing without having to know at compile time which method will be known. | |
| 6 | ||
| 7 | A very interesting property of a delegate is that it does not care about the object of the class. That it references. All matters is that methods argument type and | |
| 8 | object return type match the delegates. | |
| 9 | ||
| 10 | Creating the instance and invocation. |