Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 16, 2013 20:03
Show Gist options
  • Save Fhernd/5793221 to your computer and use it in GitHub Desktop.
Save Fhernd/5793221 to your computer and use it in GitHub Desktop.
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