public static void UseMulticastDelegate() { Console.WriteLine("Start UseMulticastDelegate"); NoteFunction multicastDelegate = null; multicastDelegate += WriteMethod; multicastDelegate += ReadMethod; multicastDelegate -= WriteMethod; WriteNoteInformation(multicastDelegate); string returnString = multicastDelegate(); Console.WriteLine(returnString); Console.WriteLine("End UseMulticastDelegate"); }
public static void UseDelegate() { Console.WriteLine("Start UseDelegate"); NoteFunction write, read; write = new NoteFunction(WriteMethod); write = WriteMethod; read = ReadMethod; write(); read(); WriteNoteInformation(write); WriteNoteInformation(new NoteFunction(CalculateMethod)); Console.WriteLine("End UseDelegate"); }
private static string WriteNoteInformation(NoteFunction writtenNote) { string returnString = ""; Console.WriteLine(); Console.WriteLine("-------------------------------- Note Information ---------------------------------"); if (writtenNote != null) { returnString = writtenNote(); } Console.WriteLine("-------------------------------- End Note Information ---------------------------------"); Console.WriteLine(); return(returnString); }