Learn about event delegation (refer to others' blogs and learn by yourself))
Using system; using system. collections. generic; using system. LINQ; using system. text; namespace consoleapplication1 {public class eventtest: eventargs {private readonly string name; Public string name {get {return name ;}} public eventtest () {} public eventtest (string name) {This. name = Name ;}} public class notice {Public Delegate void noticeeventhander (Object sender, eventtest E); public event Noticeeventhander notic; Public void issue (string name) {If (notic! = NULL) {notic (this, new eventtest (name) ;}} public class Xiaoyang {public static void sayxingqi (Object sender, eventtest e) {console. writeline (E. name + "coming off, huh, huh") ;}} public class Xiaoli {public static void sayfangjia (Object sender, eventtest e) {console. writeline ("today is" + E. name + ", it's over the weekend, you can relax, ga") ;}} public class comeon {public static void main (string [] ARGs) {notice = new notice (); Console. writeline ("Enter the day of the week? "); String name = console. readline (); If (name = "day of the week") {notice. notic + = new notice. noticeeventhander (Xiaoyang. sayxingqi); notice. notic + = Xiaoli. sayfangjia; notice. issue ("day of the week"); console. readkey ();}}}}