DEV Community

Daniel Jonathan
Daniel Jonathan

Posted on • Originally published at biztalkdj.blogspot.com on

Delegates and Events in C Sharp

In this article, I will brief about delegates and events. C# delegates are similar to pointers to functions, in C or C++. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime. Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.

Declaring, Instantiating and Multicasting of delegates

1
Below screen shot explains, void vs return type delegates

1
Events and delegates work hand-in-hand to provide a program’s functionality. Below code shows logging feature using event delegate.

1

Top comments (0)