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");
}
}
}
dXNpbmcgU3lzdGVtOwoKbmFtZXNwYWNlIEFydGljdWxvcy5DYXAwNAp7CiAgICBwdWJsaWMgZGVsZWdhdGUgdm9pZCBEZWxlZ2FkbygpOwogICAgCiAgICBwdWJsaWMgY2xhc3MgQXBsaWNhY2lvbgogICAgewogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKICAgICAgICB7CiAgICAgICAgICAgIERlbGVnYWRvIGQxID0gTWV0b2RvMTsKICAgICAgICAgICAgZDEgKz0gTWV0b2RvMjsKICAgICAgICAgICAgZDEgKz0gTWV0b2RvMzsKICAgICAgICAgICAgCiAgICAgICAgICAgIERlbGVnYWRvIGQyID0gTWV0b2RvMTsKICAgICAgICAgICAgZDIgKz0gTWV0b2RvMjsKICAgICAgICAgICAgZDIgKz0gTWV0b2RvMzsKICAgICAgICAgICAgCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCLCv2BkMWAgeSBgZDJgIHNvbiBpZ3VhbGVzPzogezB9IiwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChkMSA9PSBkMikuVG9TdHJpbmcoKSk7ICAgICAgICAgICAgLy8gVHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgRGVsZWdhZG8gZDMgPSBNZXRvZG8xOwogICAgICAgICAgICBkMyArPSBNZXRvZG8zOwogICAgICAgICAgICBkMyArPSBNZXRvZG8yOwogICAgICAgICAgICAKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIsK/YGQxYCB5IGBkM2Agc29uIGlndWFsZXM/OiB7MH0iLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGQxID09IGQzKS5Ub1N0cmluZygpKTsgICAgICAgICAgICAvLyBGYWxzZQogICAgICAgIH0KICAgICAgICAKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTWV0b2RvMSgpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiTWV0b2RvMSIpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTWV0b2RvMigpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiTWV0b2RvMiIpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTWV0b2RvMygpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiTWV0b2RvMyIpOwogICAgICAgIH0KICAgIH0KfQ==