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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit KumarPosted Apr 25, 2019, 12:21 AM
Afzaal Ahmad ZeeshanPosted Apr 24, 2019, 5:00 PM
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