Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement