What is Delegate?
· Its reference to method.
· once method assign to delegate its work like method
· delegate method used any other method
Where we will use real time?
If you want to call Function in Runtime .and to get data after you can call your function but method name you don't know design time but you know runtime during time you can use "Delegate"
Different type of Delegate:
- Single cast Delegate
- Multicast Delegate
Single cast Delegate Syntax:
Below are signature of single cast delegate
Access-modifier delegate result-type identifier ([parameters]);
Access-modifier è Its Access permission for delegate (like public ,private ..,)
Delegate è it's a Keyword
Result-type èthis is return type (like int,string,void)
Identifier è delegate name (user define)
Parameter è run time value passing
Ex :
Way 1:
public delegate void jsdelegate();
above example is no return type ,no parameter
Way 2:
public delegate string jsdelegatevalue(int x,int y);
above example is string is return type and x,y is parameter
above 2 way are delegate declaration
No comments:
Post a Comment