// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public delegate void D(string msg); public class Demo { public event D E; public void M1() { E("M1 called"); } public void M2() { E("M2 called"); } } public class Program { public static void ConsolePrint(string msg) { Console.WriteLine(msg); } public static void ConsolePrintSpecial(string msg) { Console.WriteLine(">" + msg.ToUpper() + "<"); } public static void Main(string[] args) { Demo o = new Demo(); o.E += ConsolePrint; o.M1(); o.M2(); o.E += ConsolePrintSpecial; o.M1(); o.M2(); o.E -= ConsolePrint; o.M1(); o.M2(); } } }