示例#1
0
        static void Main(string[] args)
        {
            ExampleObject.MyCallbackHandler cb;

            // anonymous delegate
            cb = delegate(object callbackData)
            {
                Console.WriteLine(callbackData);
            };

            var o = new ExampleObject();
            o.Invoke(delegate(object callbackData)
            {
                Console.WriteLine(callbackData);
            });

            // Lambda expression implementation.
            o.Invoke(d => Console.WriteLine(d));

            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            ExampleObject.MyCallbackHandler cb;

            // anonymous delegate
            cb = delegate(object callbackData)
            {
                Console.WriteLine(callbackData);
            };

            var o = new ExampleObject();

            o.Invoke(delegate(object callbackData)
            {
                Console.WriteLine(callbackData);
            });

            // Lambda expression implementation.
            o.Invoke(d => Console.WriteLine(d));

            Console.ReadLine();
        }