using System;
using System.Collections.Generic;
namespace Test{
class A{
public delegate void Callback();
private List<Callback> ls = new List<Callback>();
public void AddCallBack(Callback c){ls.Add(c);}
public void Call(){foreach(var c in ls){c();}}
}
class Test{
public static void f1(){
Console.WriteLine("f1");
}
public static void f2(int n){
Console.WriteLine("f2:"+n);
}
public static void Main(string[] args){
A a = new A();
a.AddCallBack(delegate(){f1();});
a.AddCallBack(delegate(){f2(100);});
a.Call();
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKbmFtZXNwYWNlIFRlc3R7CiAgY2xhc3MgQXsKICAgIHB1YmxpYyBkZWxlZ2F0ZSB2b2lkIENhbGxiYWNrKCk7CiAgICBwcml2YXRlIExpc3Q8Q2FsbGJhY2s+IGxzID0gbmV3IExpc3Q8Q2FsbGJhY2s+KCk7CiAgICBwdWJsaWMgdm9pZCBBZGRDYWxsQmFjayhDYWxsYmFjayBjKXtscy5BZGQoYyk7fQogICAgcHVibGljIHZvaWQgQ2FsbCgpe2ZvcmVhY2godmFyIGMgaW4gbHMpe2MoKTt9fQogIH0KICBjbGFzcyBUZXN0ewogICAgcHVibGljIHN0YXRpYyB2b2lkIGYxKCl7CiAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJmMSIpOwogICAgfQogICAgcHVibGljIHN0YXRpYyB2b2lkIGYyKGludCBuKXsKICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoImYyOiIrbik7CiAgICB9CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgTWFpbihzdHJpbmdbXSBhcmdzKXsKICAgICAgQSBhID0gbmV3IEEoKTsKICAgICAgYS5BZGRDYWxsQmFjayhkZWxlZ2F0ZSgpe2YxKCk7fSk7CiAgICAgIGEuQWRkQ2FsbEJhY2soZGVsZWdhdGUoKXtmMigxMDApO30pOwogICAgICBhLkNhbGwoKTsKICAgIH0KICB9Cn0=