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
You can pass the handler when creating the Employee:
private Employee(ctorDel construcEvent)
{
if (construcEvent != null)
this.myEvent += construcEvent;
}
public Employee(int empID,string empName, ctorDel construcEvent)
: this(construcEvent)
{
this.empID = empID;
this.empName = empName;
if (myEvent != null)
{
myEvent();
}
}
And then:
Employee emp = new Employee(id, name, new ctorDel(showMessage));