why i should use delegate as method pointer if i can do the same thing with event?
for instance: i have delegate
but i can do the same thing with events too
Please explain it to me i am so confused...
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Afzaal Ahmad ZeeshanRank #60 · 27.6K reputationPosted Apr 24, 2019, 1:00 PM EDT
With events you can only subscribe, or publish to them. With delegates you can perform other actions too, such as passing a delegate in another function as callback--although this is no longer a recommended approach and you should consider using async/await for asynchronous tasks and functions. So do not confuse yourself with the delegates and events, in C# events are the way to go when you want to have a publish-subscribe feature, and this feature is based on the delegates.
Please see this for more on the topic, https://stackoverflow.com/questions/29155/what-are-the-differences-between-delegates-and-events
Amit KumarRank #459 · 5.4K reputationPosted Apr 24, 2019, 8:21 PM EDT