kanagara

Untitled

May 24th, 2020
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System; //Delegati Func i Action se nalaze u namespace-u System.
  2.  
  3.  
  4.         Action<int> myAction = DoSomething;
  5.         myAction(123);           //Ispisuje "123"
  6.                                
  7.         Func<int, double> myFunc = CalculateSomething;
  8.         Console.WriteLine(myFunc(5));   // Ispisuje 2.5
  9.     }
  10.  
  11.     static void DoSomething(int i)
  12.     {
  13.         Console.WriteLine(i);
  14.     }
  15.  
  16.     static double CalculateSomething(int i)
  17.     {
  18.         return (double)i/2;
  19.     }
  20. }
Add Comment
Please, Sign In to add comment