public static void CallMe() { cl3 obj3 = new cl3(); del p = obj3.CallMe2(); Console.WriteLine(p.Invoke(5)); //11 Console.WriteLine(p.Invoke(7)); //13 Console.WriteLine(p.Invoke(9)); //15 }
static void Main(string[] args) { del d = new del(add); d += sub; d.Invoke(); }
public static void L7P1_Calculator() { int x = int.Parse(Console.ReadLine()); int y = int.Parse(Console.ReadLine()); string str = Console.ReadLine(); del operation = null; switch (str) { case "plus": { operation = (int x1, int y2) => x + y; break; } case "minus": { operation = Minus; break; } } var result = operation?.Invoke(x, y); Console.WriteLine(result); }
public static void L7P1_Calculator() { Console.WriteLine("enter x"); int x = int.Parse(Console.ReadLine()); Console.WriteLine("enter y"); int y = int.Parse(Console.ReadLine()); string str = Console.ReadLine(); del operation = null; switch (str) { case "plus": { operation = delegate(int x1, int y1) { return(x + y); }; break; } case "minus": { operation = Minus; break; } } var result = operation?.Invoke(x, y); Console.WriteLine(result); }
public static void ThisMain() { del d = x => Console.WriteLine(x); d.Invoke(Book.ToString()); Console.ReadLine(); }
static void Main(string[] args) { del d = x => Console.WriteLine(x); d.Invoke(Book.ToString()); Console.ReadLine(); }
public static void run(del d) { Console.WriteLine(d.Method.Name); Console.WriteLine(); d.Invoke(); Console.WriteLine(); }
static void Main() { string s = new String(new char[] { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', }); Console.WriteLine(); // \n Console.WriteLine(s); //Hello World\n Console.WriteLine(s + s); //Hello WorldHello World\n Console.WriteLine(s + 1 + s); //Hello World1Hello World\n Console.WriteLine("Hello World{0}Hello World{1}", 2, 3); //Hello World2Hello World\n Console.WriteLine($"Hello World{1 * 3}Hello World"); //Hello World3Hello World\n FileStream file = new FileStream("", FileMode.Open); StreamReader reader = new StreamReader(file); reader.Close(); file.Close(); try { int zero = 0; int i = 1; i = i / zero; throw new Exception(""); } catch (DivideByZeroException e) { Console.WriteLine(e.Message); ushort } catch { throw; } finally { } del d = new del(First); d += new del(Second); Console.WriteLine(d.Invoke()); i = new del(First); i += d; i.Invoke(); Console.ReadLine(); }
public static void Execute() { del d = GetHello; d += GetHello; Console.WriteLine(d?.Invoke("Athar")); Console.WriteLine("===================================="); Console.WriteLine(d("Imam")); }
//internal void RunMap(del meth) //{ // Task task = new Task(() => RunMap1(meth)); // task.Start(); // task.Wait(); //} /// <summary> /// Запуск генерации /// </summary> /// <param name="method"></param> public void RunMap(del method) { for (; CurIteration < NumIterations; CurIteration++) { foreach (Point on in _points.ToArray()) { on.Action(this); } method.Invoke(this, new EventArgs()); } ; MessageBox.Show("Iterations end"); }
static void Main(string[] args) { del d = x => Console.WriteLine(x); d.Invoke(Movie.ToString()); }
static void Main(string[] args) { bool work = true; while (work) { System.Console.WriteLine("Выберите операцию(*,/,+,-):"); System.Console.WriteLine("1.умножения(*):"); System.Console.WriteLine("2.деление(/):"); System.Console.WriteLine("3.плюс(+):"); System.Console.WriteLine("4.минус(-):"); System.Console.WriteLine("5.Выход:"); string choice = Console.ReadLine(); switch (choice) { case "1": { System.Console.Write("Наберите число А: "); double A = double.Parse(Console.ReadLine()); System.Console.Write("Наберите число В: "); double B = double.Parse(Console.ReadLine()); del <double> mult = Multiply <double>; double result = mult(A, B); System.Console.WriteLine("======================"); System.Console.WriteLine($"ответ->{result}"); System.Console.WriteLine("======================"); }; break; case "2": { System.Console.Write("Наберите число А"); double A = double.Parse(Console.ReadLine()); System.Console.Write("Наберите число В"); double B = double.Parse(Console.ReadLine()); if (A != 0 && A != 0) { del <double> div = Divide <double>; double result = div(A, B); System.Console.WriteLine("======================"); System.Console.WriteLine($"ответ->{result}"); System.Console.WriteLine("======================"); } else { System.Console.WriteLine("Error!!!"); } }; break; case "3": { System.Console.Write("Наберите число А "); double A = double.Parse(Console.ReadLine()); System.Console.Write("Наберите число В "); double B = double.Parse(Console.ReadLine()); del <double> sum = Sum <double>; double result = sum.Invoke(A, B); Console.ForegroundColor = ConsoleColor.Green; System.Console.WriteLine("======================"); System.Console.WriteLine($"ответ-> {result}"); System.Console.WriteLine("======================"); Console.ForegroundColor = ConsoleColor.White; }; break; case "4": { System.Console.Write("Наберите число А "); double A = double.Parse(Console.ReadLine()); System.Console.Write("Наберите число "); double B = double.Parse(Console.ReadLine()); del <double> min = Minus <double>; double result = min.Invoke(A, B); Console.ForegroundColor = ConsoleColor.Green; System.Console.WriteLine("======================"); System.Console.WriteLine($"ответ-> {result}"); System.Console.WriteLine("======================"); Console.ForegroundColor = ConsoleColor.White; }; break; case "5": work = false; break; default: System.Console.WriteLine("======================"); Console.WriteLine("You are writed wrong number!!!"); System.Console.WriteLine("======================"); break; } } }
void ReferenceType() { del d = x => Console.WriteLine(x); d.Invoke(Book.ToString()); }