3
Reply

What are delegates and why are they required?

John

John

12y
6.5k
0
Reply

    A delegate is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method. The delegate method can be used like any other method, with parameters and a return value, as in this example:public delegate int PerformCalculation(int x, int y);

    Delegate is a function pointer. We can pass method as a parameter.Public Delegate bool DelActive();Static voind main() {DelActive a= new DelActive(IsDone);IsUser(a); bool IsDone() {int x=10;if(x==10) {return true; } else {return false; } } }Class sample {Public bool IsUser(DelActive active) {if(active) { return true; } else {return false; } } }

    Delegate is a function pointer. We can pass method as a parameter.Public Delegate bool DelActive();Static voind main() {DelActive a= new DelActive(IsDone);IsUser(a); bool IsDone() {int x=10;if(x==10) {return true; } else {return false; } } }Class sample {Public bool IsUser(DelActive active) {if(active) { return true; } else {return false; } } }