+ 1
Why do we need delegates
so as much as I know delegate is a pointer to a function so why do we need to run a function indirectly when I can do it on myself which is much more easier , what are the befifits to use a delegate
5 odpowiedzi
+ 4
You never 'need' to use one thing, there's almost always different approaches.
But they are perfect for things like button events.
Or, if you need to call a bunch of methods always in synch (one after another), they are very elegant for doing that.
+ 11
Not that I know C#, but this might be a beneficial read:
https://stackoverflow.com/questions/2019402/when-why-to-use-delegates
+ 4
Delegates are easier. They make things more 'elegant' and compact when used properly.
You don't 'need' them though.
They are excellent if you ever want to pass methods as parameters.
For example, button events: to define what methods would be called on click.
0
thanks man but any real need to use delegates?
0
thanks a Lot man