static void Main(string[] args) { Campainha campainha = new Campainha(); //campainha.Tocar(); //campainha.OnCampainhaTocou = new Action(() => { }); campainha.OnCampainhaTocou += CampainhaTocou1; campainha.OnCampainhaTocou += CampainhaTocou2; campainha.Tocar(); Console.ReadKey(); }
static void Main(string[] args) { Campainha campainha = new Campainha(); campainha.OnCampainhaTocou += CampainhaTocou1; campainha.OnCampainhaTocou += CampainhaTocou2; Console.WriteLine("A campainha será tocada"); campainha.Tocar(); campainha.OnCampainhaTocou -= CampainhaTocou2; Console.WriteLine("A campainha será tocada"); campainha.Tocar(); }