Ejemplo n.º 1
0
        static void Main1(string[] args)
        {
            Mydele obj = new Mydele(Display);

            obj(5);

            Mydele1 obj1 = new Mydele1(add);
            int     i    = obj1(5);

            Console.WriteLine("add method called with delegate and addition is: " + i);
            Mydel2 obj2 = new Mydel2(multiply);
            int    c    = obj2(5, 6);

            Console.WriteLine("Multiply method called " + c);

            //Method in another class
            Class1 o    = new Class1();
            Mydel3 obj3 = Class1.divide;
            int    d    = obj3(25, 25);

            Console.WriteLine("Divide method called " + d);

            dele ob = o.dis;

            ob();
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            int    A   = 0;
            Mydele fun = x => x + 2;

            while (A < 10)
            {
                Console.WriteLine("It's incremented by 2 using Lamda function {0}", A);
                A = fun(A);
            }
        }
Ejemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            mydele = new Mydele(GetText);

            var s1s = Thread.CurrentThread.ManagedThreadId;

            mydele.BeginInvoke("2", Callbacs, null);


            Thread.Sleep(1000);
            this.textBox1.Text = "call back之前";

            var s3s = Thread.CurrentThread.ManagedThreadId;
        }