private static void MultiCastDelegate() { DelSimplePrint MyPrintMethods; MyPrintMethods = new DelSimplePrint(DisplayInConsole); MyPrintMethods += DisplayInDialog; MyPrintMethods("Amir from MultiCast Delegates"); }
private static void AnonymousMethods() { DelSimplePrint myPrintDel = delegate(string str) { System.Console.WriteLine("from an anonymous method"); System.Console.WriteLine(str); }; myPrintDel("*Amir from an anonymous delegate*"); }
private static void SimpleDelegate() { string input = "Amir from simple Delegates"; DelSimplePrint myPrintMehod; myPrintMehod = DisplayInConsole; //Simplified syntax DelSimplePrint myPrintMehod2 = new DelSimplePrint(DisplayInConsole); // the backwards compatible way. Pre c# 2.0 syntax myPrintMehod(input); }