Answer the question
In order to leave comments, you need to log in
Event is value or reference type in C#?
Event is value or reference type in C#? Justify your answer please.
Answer the question
In order to leave comments, you need to log in
event is related to a delegate instance ( Stanislav Makarov : multicast ) as property is related to a field value.
event is syntactic sugar, a wrapper for add and remove methods, just as property is a wrapper for get and set methods.
So the question is incorrect since event is not a type.
1) An event is the same delegate, only with a truncated interface for external calls (outside the class). Only the operations of adding and removing a handler get into the public interface of the class from the event. You can invoke an event delegate from within the class, but you cannot invoke it from outside the class (i.e. like this: button1.Clicked(new EventArgs(...)) );
2) Since we found out that the event is a delegate (multicast, moreover), then we go and make sure that the delegate is a reference type: https://msdn.microsoft.com/en-us/library/system.mu. ..
Exam on the nose? Successful submission!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question