Created
May 31, 2014 15:34
Igualdad en multicast de delegados en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Articulos.Cap04 | |
{ | |
public delegate void Delegado(); | |
public class Aplicacion | |
{ | |
public static void Main() | |
{ | |
Delegado d1 = Metodo1; | |
d1 += Metodo2; | |
d1 += Metodo3; | |
Delegado d2 = Metodo1; | |
d2 += Metodo2; | |
d2 += Metodo3; | |
Console.WriteLine("¿`d1` y `d2` son iguales?: {0}", | |
(d1 == d2).ToString()); // True | |
Delegado d3 = Metodo1; | |
d3 += Metodo3; | |
d3 += Metodo2; | |
Console.WriteLine("¿`d1` y `d3` son iguales?: {0}", | |
(d1 == d3).ToString()); // False | |
} | |
public static void Metodo1() | |
{ | |
Console.WriteLine("Metodo1"); | |
} | |
public static void Metodo2() | |
{ | |
Console.WriteLine("Metodo2"); | |
} | |
public static void Metodo3() | |
{ | |
Console.WriteLine("Metodo3"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment