Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace EventsExercise
- {
- public delegate void EventHandler();
- public class Program
- {
- public static event EventHandler subscribe;
- static void Main(string[] args)
- {
- Button btn1 = new Button("Armando");
- subscribe += new EventHandler(btn1.Subscribe);
- Button btn2 = new Button("Elizabeth");
- subscribe += new EventHandler(btn2.Subscribe);
- subscribe.Invoke();
- }
- }
- public class Button
- {
- public string Name { get; set; }
- public Button(string name)
- {
- this.Name = name;
- }
- public void Subscribe()
- {
- Console.WriteLine($"Succesfully subscribed, {this.Name}");
- }
- }
- }
Add Comment
Please, Sign In to add comment