Delegate plays an important role in today's programming model where it is extensively used in Parallel Programming, Asynchronous Programming, PLINQ, Events & Callback methods, Func, Action, Predicates and so on.
Introduction
Introduction
Modern development tools & languages are full with easy use of tedious functionalities like threading, asynchronous programming, and so on. A developer just need to use ready-made mechanism (APIs/Functions) and rest is done by language or .net system library.
Background
Background
Its looks like programming is now so simplified that anyone can write higher level code like multi-threading & asynchronous. It sound cool, but to write an efficient & optimized code, a programmer must have a good understanding on fundamental items like-
- In terms of Hardware - CPU architecture, memory model, IO operations and OS management on resources
- In terms of Programming – Types, Delegate, LINQ and so on.
Let’s understand the “type” in the following simple points-
- Almost everything in .NET is object (except interface type, pointer type, open parameter type, type & args)
- Most of types are derived from System.Object
- There are some types which are not derived from anything.
Let me define to delegate the following points-
- An object (variable), used to hold the address of function.
- Same type of delegate objects can be composed & discomposed using the "+" and "-" operator respectively. This is called Multi-casting.
If we further drill down on above definition, we can conclude that,
- An Object: It means delegate is of reference type (derived from System.Delegate class).
- hold the address: (a) It is like pointers to function. (b) we can also conclude here, that this address can be changed to any function (which is of same signature).

Ehsan SajjadPosted Jan 13, 2016, 11:41 AM
Very good
Sibeesh VenuPosted Dec 30, 2015, 3:28 AM
Nice Share
Shridhar SharmaPosted Dec 30, 2015, 1:31 AM
nice share
ShehzadPosted Dec 29, 2015, 9:05 PM
Another Delegate Classic, Thanks for sharing...