fork download
  1. using System;
  2.  
  3. namespace Delegate
  4. {
  5. class Hoge
  6. {
  7. public EventHandler Piyo;
  8. public Hoge() { }
  9. public void Raise() { Piyo(null, EventArgs.Empty); }
  10. }
  11.  
  12. class Program
  13. {
  14. static void Main()
  15. {
  16. Hoge hoge = new Hoge();
  17. hoge.Piyo += Hoge1;
  18. hoge.Piyo += Hoge2;
  19. hoge.Piyo += Hoge3;
  20. hoge.Raise();
  21.  
  22. var mcd = (MulticastDelegate)hoge.Piyo;
  23. var list = mcd.GetInvocationList();
  24. }
  25.  
  26. static void Hoge1(object sender, EventArgs e) { System.Diagnostics.Debug.Print("Hope1"); }
  27. static void Hoge2(object sender, EventArgs e) { System.Diagnostics.Debug.Print("Hope2"); }
  28. static void Hoge3(object sender, EventArgs e) { System.Diagnostics.Debug.Print("Hope3"); }
  29. }
  30. }
  31.  
Success #stdin #stdout 0.01s 33584KB
stdin
Standard input is empty
stdout
Standard output is empty