Advertisement
Guest User

Untitled

a guest
Aug 31st, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5.     public delegate void Print(int value);
  6.     public static void Main()
  7.     {
  8.         PrintHelper(PrintNumber, 10000);
  9.         PrintHelper(PrintMoney, 10000);
  10.         /* NEW METHOD */
  11.         PrintHelper(PlusTwentyFive, 9975);
  12.  
  13.         /* ~ returns ~
  14.          * Number: 10,000      
  15.          * Money: $10,000.00
  16.          * NumberPlusTwentyFive: 10,000 */
  17.     }
  18.  
  19.     public static void PrintHelper(Print delegateFunction, int numToPrint)
  20.     {
  21.         delegateFunction(numToPrint);
  22.     }
  23.  
  24.     /* NEW METHOD */
  25.     public static void PlusTwentyFive(int num)
  26.     {
  27.         Console.WriteLine("NumberPlusTwentyFive: {0,-12:N0}", (num + 25)); 
  28.     }
  29.    
  30.     public static void PrintNumber(int num)
  31.     {
  32.         Console.WriteLine("Number: {0,-12:N0}", num);
  33.     }
  34.  
  35.     public static void PrintMoney(int money)
  36.     {
  37.         Console.WriteLine("Money: {0:C}", money);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement