static void Main(string[] args) { string s = Console.ReadLine(); string[] n = s.Split(' '); int a = int.Parse(n[0]); int b = int.Parse(n[1]); Summa summa = new Summa(a, b); MyDelegete D = summa.Sum; Thread.Sleep(1000); //for (int i = 0; i < 9; ++i) //{ // Console.SetCursorPosition(0, 1); // Console.Write(i + 1); // Thread.Sleep(1000); //} //Console.SetCursorPosition(0, 1); Console.WriteLine(D.Invoke()); }
static void Main(string[] args) { SumSubtract ss = new SumSubtract(); MyDelegete md = new MyDelegete(ss.Sum); // 호출아닌 이름만 넘기면 됨 Console.WriteLine(md(1, 2)); // static은 클래스 소속이기 때문에 ss안됨. 클래스 이름을 적어줄 것! md = new MyDelegete(SumSubtract.Subtract); Console.WriteLine(md(10, 3)); }
static void Main(string[] args) { MyDelegete myDelegete; MyDelegete myDelegete1 = delegate(int x) { return(x * 10); }; // MyDelegete myDelegete2 = (x) => { return(x * 6); }; // MyDelegete myDelegete3 = x => x * 5; // myDelegete = myDelegete1 + myDelegete2 + myDelegete3; int s = myDelegete(10); Console.WriteLine(s); Console.ReadKey(); }
public void CustomerDelegete() { MyDelegeteParams customerDelegeteParams = _customerManager.Add; customerDelegeteParams("Rahim"); MyDelegeteParams productDelegeteParams = _productManager.Add; productDelegeteParams("Monster PC"); MyDelegete customerDelegete = _customerManager.Add; customerDelegete += _customerManager.SendMessage; customerDelegete += _customerManager.ShowAlert; customerDelegete(); }
static void Main(string[] args) { MyDelegete mydelegat = null; MyDelegete mydelegat1 = new MyDelegete(Method1); MyDelegete mydelegat2 = new MyDelegete(Method2); MyDelegete mydelegat3 = new MyDelegete(Method3); mydelegat = mydelegat1 + mydelegat2 + mydelegat3; Console.WriteLine("Enter your number pls."); label : string choise = Console.ReadLine(); int n = Int32.Parse(choise); switch (n) { case 1: { mydelegat1.Invoke(); break; } case 2: { mydelegat2.Invoke(); break; } case 3: { mydelegat3.Invoke(); break; } case 4: { MyDelegete mydelegat4 = mydelegat - mydelegat1; mydelegat4.Invoke(); break; } case 5: { MyDelegete mydelegat5 = mydelegat - mydelegat2; mydelegat5.Invoke(); break; } case 6: { MyDelegete mydelegat6 = mydelegat - mydelegat3; mydelegat6.Invoke(); break; } case 7: { mydelegat.Invoke(); break; } default: { Console.WriteLine("You enter wrong number!! --please try again!!"); goto label; } } Console.ReadKey(); }