Advertisement
Blizzardo1

Delegate Test

Mar 19th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. namespace delegate_test
  4. {
  5.     delegate int PrintHandler( string message );
  6.     public static class Program {
  7.         private static PrintHandler _print;
  8.         private static Test _test;
  9.         private static void Main(string[] args) {
  10.             _test = new Test( );
  11.             _print = _test.Print;
  12.             int res = _print( "Hello, World" );
  13.             Console.WriteLine( $"Return length of _print is {res}" );
  14.  
  15.         }
  16.     }
  17.  
  18.     public class Test
  19.     {
  20.         public int Print(string message)
  21.         {
  22.             Console.WriteLine( message );
  23.             return message.Length;
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement