Can we use Events without declaring Delegate in C#?
Need more clarification on events in C#.
Can we use Events without declaring Delegate in C#?
Need more clarification on events in C#.
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.
Rijwan AnsariPosted Mar 4, 2022, 6:29 AM
Gajendra JangidPosted Mar 10, 2022, 11:20 AM
A delegate basically describes a function type. An event is a hook where registered functions matching a given function type are called when the event occurs.
Putting together these two simplified definitions, a delegate is also a descriptor for an event, therefore you cannot have an event without a related delegate.
Anyway, you are not forced to declare a new delegate for every event you declare. Instead, you can use any of the preexisting delegates such as
EventHandler,EventHandleror even any of theActionoverloads, choosing in the one that fits you best in each case.Dhanush KPosted Mar 5, 2022, 2:54 PM
Thank you!
Thank you Rijwan Ansari sir for your response