C# 委托与字典

发布时间 2023-04-07 23:15:39作者: 老杨_在路上

private delegate int delStepDoSomething(object obj=null);
private static Dictionary<int , delStepDoSomething> stepDoSomething = new Dictionary<int , delStepDoSomething>();
private static Dictionary<int, Func<object,int>> stepDoSomething = new Dictionary<int,Func<object, int>>();

1.注意,上面2中方式的委托。都可以与字典绑定

2.Func作为委托,其参数没办法,给默认值