The program with event is modify to get the same output without event. How can this situation be explained?
Without event public static event EventHandler _show; is comment out and EventHandler _show = new EventHandler(Dog); is added.
With Event
using System;
public delegate void EventHandler();
class Program
{
public static event EventHandler _show;
static void Main()
// Add event handlers to Show event.
_show += new EventHandler(Dog);
_show += new EventHandler(Cat);
_show += new EventHandler(Mouse);
// Invoke the event.
_show.Invoke();
Console.ReadKey();
}
static void Cat()
Console.WriteLine("Cat");
static void Dog()
Console.WriteLine("Dog");
static void Mouse()
Console.WriteLine("Mouse");
/*
Dog
Cat
Mouse
*/
Without Event
//public static event EventHandler _show; comment out
EventHandler _show = new EventHandler(Dog); //This is added
//_show += new EventHandler(Dog);