Created
June 16, 2013 20:03
-
-
Save Fhernd/5793221 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
public delegate void MiDelegado(); // declaración de delegado | |
public interface I | |
{ | |
event MiDelegado MiEvento; | |
void Activar(); | |
} | |
public class MiClase: I | |
{ | |
public event MiDelegado MiEvento; | |
public void Activar() | |
{ | |
if (MiEvento != null) | |
MiEvento(); | |
} | |
} | |
public class ClasePrincipal | |
{ | |
static private void f() | |
{ | |
Console.WriteLine("Este método es llamado cuando el evento ocurre."); | |
} | |
static public void Main () | |
{ | |
I i = new MiClase(); | |
i.MiEvento += new MiDelegado(f); | |
i.Activar(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment