Using one delegate to for several methods with different parameters

后端 未结 4 812
时光取名叫无心
时光取名叫无心 2021-01-20 19:22

Is it possible to use one delegate for several methods with different parameters somehow? I use reflection to get all the methods in a class, and I want to assign each of th

4条回答
  •  悲&欢浪女
    2021-01-20 19:52

    You can use the Delegate.CreateDelegate Function and pass the appropriate delegate Type (Action<> or Func<>) and an instance of the MethodInfo, in this case you should construct the delegate type according to the MethodInfo parameters.

提交回复
热议问题