lenelex.com
Home
Quizzes
Games
Register
Log in
Question 1 of 4
Consider the code below. Which of the following statements correctly subscribes to the event.
public delegate void EventHandler(object sender, EventArgs e); class EventSender { public event EventHandler Event; public void Send() { if (Event != null) { Event(this, EventArgs.Empty); } } } class Program { static void Main() { var E = new EventSender(); /* Your solution goes here */ E.Send(); } private static void Sender_Event(object sender, EventArgs e) { Console.Write("Event"); } }
A. E.Event += Sender_Event;
B. E.Event = Sender_Event;
C. E.Event -= Sender_Event;
D. Sender_Event = E.Event;
Links:
event
Subscribe to and Unsubscribe from Events