private void BroadcastingExample() { String cityName = "San Francisco"; Console.WriteLine("Using delegates to broadcast a string manipulation: {0}", cityName); // A delegate instance is a referece (similar to a pointer) to one or more methods StringManipulatorDelegate del = null; // First method to be delegated to executem, it's a reference and not call to the method. del += ReverseMyString; // Another one added (order of execution is the same as the addition) del += UpperMyString; // One more method to add del += RemoveVowelsMyString; // Calling the delegate, broadast the call to all delegated functions del(cityName); // Remove a delegate method del -= RemoveVowelsMyString; del(cityName); }
public static void Tranform(String name, StringManipulatorDelegate del) { del(name); }