static void Main(string[] args) { Dlg d1 = new Dlg(MyMethods.Sum); int result = d1.Invoke(50, "Armenia"); Console.WriteLine("Result = " + result); Dlg d2 = MyMethods.Sum; int rst = d2(121, "Erevan Dardzac , Im Erebuniiii ... !"); Console.WriteLine("Result is " + rst); d2 += MyMethods.Multy; int r = d2(119, "Sona"); Console.WriteLine(r); }
static void Main(string[] args) { Dlg d1 = new Dlg(MyMethods.Sum); int result = d1.Invoke(50, "Armenia"); Console.WriteLine("Result is " + result); Dlg d2 = MyMethods.Sum; int rst = d2(121, "Erevan"); Console.WriteLine("Res is " + rst); d2 += MyMethods.Multy; MyMethods md = new MyMethods();// kamel karelie "d2+= new MyMethods().Sub;" d2 += md.Sub; int r = d2(119, "Sona"); Console.WriteLine(r); Delegate[] dl = d2.GetInvocationList(); foreach (Dlg g in dl) { Console.WriteLine(g.Method.Name + "\t" + g.Target); } }