C# DelegatesIn C#, delegate is a reference to the method. It works like function pointer in C and C++. But it is objected-oriented, secured and type-safe than function pointer. For static method, delegate encapsulates method only. But for instance method, it encapsulates method and instance both. The best use of delegate is to use as event. Internally a delegate declaration defines a class which is the derived class of System.Delegate. C# Delegate ExampleLet's see a simple example of delegate in C# which calls add() and mul() methods. Output: After c1 delegate, Number is: 120 After c2 delegate, Number is: 360 Next TopicC# Reflection |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India