// 3) Add registration function for the caller. //public void RegisterWithCarEngine(CarEngineHanlder methodToCall) { // listOfHandlers = methodToCall; //} // Now with multicasting support! // Note we are now using the += operator, not // the assignment operator(=). public void RegisterWithCarEngine(CarEngineHanlder methodToCall) { // This provides the registration listOfHandlers += methodToCall; // This is actuall calling the Delegate.Combine() method }
// Remove methods from the delegate's object public void UnRegisterWithCarEngine(CarEngineHanlder methodToCall) { listOfHandlers -= methodToCall; }