Advertisement
Guest User

Untitled

a guest
Aug 31st, 2018
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 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.  
  11.         /* ~ returns ~
  12.          * Number: 10,000
  13.          * Money: $10,000.00 */
  14.     }
  15.  
  16.     public static void PrintHelper(Print delegateFunction, int numToPrint)
  17.     {
  18.         delegateFunction(numToPrint);
  19.     }
  20.  
  21.     public static void PrintNumber(int num)
  22.     {
  23.         Console.WriteLine("Number: {0,-12:N0}", num);
  24.     }
  25.  
  26.     public static void PrintMoney(int money)
  27.     {
  28.         Console.WriteLine("Money: {0:C}", money);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement