i created a class and when i create an employee object via form , i want to give a message;
this is my class, event and delegate
public delegate void cto
It doesn't make sense to raise an instance event in the constructor, because since the initialization of the instance is not yet complete, there can't be any handler attached to the event...
However, you could create a static event:
public static event ctorDel myEvent;
...
Employee.myEvent += new ctorDel(showMessage);
(but don't subscribe to the event every time you create an Employee
, or the handler will be invoked as many times as there are instances...)