Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         public delegate int Plus(int number);
  12.  
  13.         static void Main(string[] args)
  14.         {
  15.             Plus plusWat;
  16.             int result;
  17.  
  18.             plusWat = Plus1;
  19.             result = plusWat(1);
  20.             Console.WriteLine(result);
  21.  
  22.             plusWat = Plus2;
  23.             result = plusWat(1);
  24.             Console.WriteLine(result);
  25.  
  26.             Console.WriteLine(DoeIets(6, Plus2));
  27.            
  28.             Console.ReadLine();
  29.         }
  30.  
  31.         public static int DoeIets(int number, Plus function)
  32.         {
  33.             return function(number);
  34.         }
  35.  
  36.         public static int Plus1(int number)
  37.         {
  38.             return number + 1;
  39.         }
  40.  
  41.         public static int Plus2(int number)
  42.         {
  43.             return number + 2;
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement