예제 #1
0
        static void AnonymousMethodDemo()
        {
            Anonymous a = new Anonymous();

            a.anonymousMethod = new PrintNameHelper((string f, string l) => { Console.WriteLine($"{f} {l}"); });
            a.anonymousMethod("Abhishek", "Mishra");

            var anonymousMethod = new PrintNameHelper((string f, string l) => {
                Console.WriteLine($"{f} {l} direct delegate");
            });

            anonymousMethod("Abhishek", "Mishra");

            PrintNameHelper del = delegate(string f, string l)
            {
                Console.WriteLine($"{f} {l} direct delegate 2");
            };

            del("siku", "mishra");
        }