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(); }
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); } }
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; }