Advertisement
Fhernd

IgualdadMulticast.cs

Jul 26th, 2014
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Articulos.Cap04
  4. {
  5.     public delegate void Delegado();
  6.    
  7.     public class Aplicacion
  8.     {
  9.         public static void Main()
  10.         {
  11.             Delegado d1 = Metodo1;
  12.             d1 += Metodo2;
  13.             d1 += Metodo3;
  14.            
  15.             Delegado d2 = Metodo1;
  16.             d2 += Metodo2;
  17.             d2 += Metodo3;
  18.            
  19.             Console.WriteLine("¿`d1` y `d2` son iguales?: {0}",
  20.                               (d1 == d2).ToString());            // True
  21.                              
  22.             Delegado d3 = Metodo1;
  23.             d3 += Metodo3;
  24.             d3 += Metodo2;
  25.            
  26.             Console.WriteLine("¿`d1` y `d3` son iguales?: {0}",
  27.                               (d1 == d3).ToString());            // False
  28.         }
  29.        
  30.         public static void Metodo1()
  31.         {
  32.             Console.WriteLine("Metodo1");
  33.         }
  34.        
  35.         public static void Metodo2()
  36.         {
  37.             Console.WriteLine("Metodo2");
  38.         }
  39.        
  40.         public static void Metodo3()
  41.         {
  42.             Console.WriteLine("Metodo3");
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement