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.
Rijwan AnsariRank #82 · 24.2K reputationPosted Mar 4, 2022, 1:29 AM EST
Dhanush KRank #1,037 · 1.9K reputationPosted Mar 5, 2022, 9:54 AM EST
Thank you!
Thank you Rijwan Ansari sir for your response
Gajendra JangidRank #157 · 14.9K reputationPosted Mar 10, 2022, 6:20 AM EST
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.Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts