c#委托应该怎么使用
答案:1 悬赏:0 手机版
解决时间 2021-11-19 23:49
- 提问者网友:遮云壑
- 2021-11-18 23:58
c#委托应该怎么使用
最佳答案
- 五星知识达人网友:玩家
- 2021-11-19 00:39
class Program{
public void A(Action next){
Console.WriteLine("=====This is A method Start========");
next();
Console.WriteLine("=====This is A method End========
");
}
public void B(Action next){
Console.WriteLine("=====This is B method Start========");
next();
Console.WriteLine("=====This is B method End========
");
}
static void Main(string[] args){
Program program = new Program();
Action action = program.A;
action +=program.B;
action((Action)(() => { Console.WriteLine("yep,this is very good!"); }));
Console.ReadKey(true);
}
}
public void A(Action next){
Console.WriteLine("=====This is A method Start========");
next();
Console.WriteLine("=====This is A method End========
");
}
public void B(Action next){
Console.WriteLine("=====This is B method Start========");
next();
Console.WriteLine("=====This is B method End========
");
}
static void Main(string[] args){
Program program = new Program();
Action action = program.A;
action +=program.B;
action((Action)(() => { Console.WriteLine("yep,this is very good!"); }));
Console.ReadKey(true);
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯