Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created May 31, 2014 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/1c1b89d6974e95c01941 to your computer and use it in GitHub Desktop.
Save Fhernd/1c1b89d6974e95c01941 to your computer and use it in GitHub Desktop.
Igualdad en multicast de delegados en C#.
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