If a class declares a event then event can be fired only from that class. what is the reason for the restriction of the event invocation?
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication12
{
delegate void Function();
class EventHandling
{
public event Function fun;
public void AddEvents(Function events)
{
fun += events;
}
public void Notify()
{
fun();
}
}
class Program
{
static void Main(string[] args)
{
EventHandling aEvtHandler = new EventHandling();
Function aFun = new Function(Display);
aEvtHandler.AddEvents(aFun);
aEvtHandler.Notify();
}
static void Display()
{
Console.WriteLine("in the display");
Console.Read();
}
}
}