fork download
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Test{
  4. class A{
  5. public delegate void Callback();
  6. private List<Callback> ls = new List<Callback>();
  7. public void AddCallBack(Callback c){ls.Add(c);}
  8. public void Call(){foreach(var c in ls){c();}}
  9. }
  10. class Test{
  11. public static void f1(){
  12. Console.WriteLine("f1");
  13. }
  14. public static void f2(int n){
  15. Console.WriteLine("f2:"+n);
  16. }
  17. public static void Main(string[] args){
  18. A a = new A();
  19. a.AddCallBack(delegate(){f1();});
  20. a.AddCallBack(delegate(){f2(100);});
  21. a.Call();
  22. }
  23. }
  24. }
Success #stdin #stdout 0.04s 37048KB
stdin
Standard input is empty
stdout
f1
f2:100