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
What is it you're trying to accomplish? The reason what you've tried doesn't work is because you're attaching your delegate after the ctor. Once you've called "new Employee" the event is long since fired.
If you really need such an event, create a factory class:
public delegate void EmpCreated();
public EmployeeFactory {
public event EmpCreated myEvent;
public Employee Create(int empId, string empName){
var result = new Employee(empId, empName);
if(myEvent != null) myEvent();
return result;
}
}
Subscribe to the event on the factory class and you'll get the event.