void mm_NewMail(object sender, NewMailEventArgs e) { Console.WriteLine("From: {0}, To: {1}, Subject: {2}", e.From, e.To, e.Subject); }
//Create a method responsible for raising the event. //It should not called from outside. //Also marked virtual for derived class to override it. protected virtual void OnNewMail(NewMailEventArgs args) { var temp = NewMail; if (temp != null) { temp(this, args); } }
//Don't do anything. Don't want to inform anyone on new email. protected override void OnNewMail(NewMailEventArgs args) { Console.WriteLine("Top Secret. Can't disclose."); }