Advertisement
SnowPhoenix347

Untitled

Apr 22nd, 2020
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3.     Action<int, int> op;
  4.     op = Add;
  5.     Operation(10, 6, op);
  6.     op = Substract;
  7.     Operation(10, 6, op);
  8.  
  9.     Console.Read();
  10. }
  11.  
  12. static void Operation(int x1, int x2, Action<int, int> op)
  13. {
  14.     if (x1 > x2)
  15.         op(x1, x2);
  16. }
  17.  
  18. static void Add(int x1, int x2)
  19. {
  20.     Console.WriteLine("Сумма чисел: " + (x1 + x2));
  21. }
  22.  
  23. static void Substract(int x1, int x2)
  24. {
  25.     Console.WriteLine("Разность чисел: " + (x1 - x2));
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement