Delegate is type that references a method of a given signature [that is for given input and output
parameters]. Delegates are type safe as you can refer any method with the signature specified in the
declaration of the delegate.
Delegates are of two types
1 Simple / Singlecast delegate.
2. Multicast delegate.
Simple / Singlecast delegate
Type name is “System.Delegate”. Using this we can reference a method with matching signature of
delegate declaration.
Multicast delegate
Type name is “System.MulticastDelegate”. Using this we can reference any number methods with
matching signature of delegate declaration. Multicast delegate is being used asp.net for event handling
mechanism due to which people call this as “Event delegate”.
For the methods referenced by multicast delegate return type should be void. When you
observe the events in your asp.net webpage code behind, you will notice that all the event methods has
return type void.
parameters]. Delegates are type safe as you can refer any method with the signature specified in the
declaration of the delegate.
Delegates are of two types
1 Simple / Singlecast delegate.
2. Multicast delegate.
Simple / Singlecast delegate
Type name is “System.Delegate”. Using this we can reference a method with matching signature of
delegate declaration.
Multicast delegate
Type name is “System.MulticastDelegate”. Using this we can reference any number methods with
matching signature of delegate declaration. Multicast delegate is being used asp.net for event handling
mechanism due to which people call this as “Event delegate”.
For the methods referenced by multicast delegate return type should be void. When you
observe the events in your asp.net webpage code behind, you will notice that all the event methods has
return type void.
No comments:
Post a Comment