a .NET object which points to a method that matches its specific signature.
Delegates are function pointers that point to function of matching signatures. Function pointers which are extensively used in c/c++ to points to a function holds only the memory address of the function, it doesn't carry further information about the function parameters, return type etc. On the other hand .NET framework has introduced a type-safe mechanism called delegates, with automatic verification of the signature by the compiler.
So we can say that delegates are type-safe, object oriented, secure .NET objects which can be used to invoke methods of matching signature.
While using delegates it is very much necessary to make sure that the functions which the delegates points has the same number of argument type and same return type. For example if we have a method that takes a single string as a parameter and another method that takes two string parameters, then we need to have two separate delegate type for each method.
Delegates are of two types:
* If a delegate invokes a single method, then it is called as a Single cast delegate.
* Single-cast Delegates refer to a single method with matching signature.
They are derived from the System.Delegate class
*They are nothing but a single delegate that can invoke multiple methods of matching signature.
*Derives from System.MulticastDelegate class which is a subclass of System.Delegate
*In this, we create a single delegate that in turn invokes multiple encapsulated methods.
We can use Multi-cast Delegates when multiple calls to different methods are required.
if we are required to call two methods on a single button click event or mouse over event then using Multi-cast Delegates we can easily call the methods.
For more information, you can go through the following link,
Shree M.Munder2013, if this helps please login to Mark As Answer. | Alert Moderator