Example #1
0
        static void Main(string[] args)
        {
            DaiDien func = HelloWorld; //Tham chiếu tới phương thức Helloworld

            func();                    //Thực thi phương thức vừa tham chiếu tới
            Console.WriteLine("Test GitHub");
        }
Example #2
0
        static void Main(string[] args)
        {
            //Phương thức mở rộng lấy AnonymousMethod làm đại diện cho phương thức
            //Phương thức này có dạng phải giống với delegate
            DaiDien AnonymousMethod = delegate() { Console.WriteLine("Hello world !!!"); };

            AnonymousMethod();  //Thực thi phương thức không tên
            //Console: Hello World !!!
            //Cách viết khác
            //=> : go to thực thi câu lệnh
            DaiDien LambdaExpression = () => Console.WriteLine("Hello world !");

            LambdaExpression(); //Thực thi phương thức
        }