Can I get the signature of a C# delegate by its type?

前端 未结 1 1652
傲寒
傲寒 2020-12-24 02:04

Is there a straightforward way using reflection to get at the parameter list for a delegate if you have its type information?

For an example, if I declare a delegate

相关标签:
1条回答
  • 2020-12-24 02:36
        MethodInfo method = delegateType.GetMethod("Invoke");
        Console.WriteLine(method.ReturnType.Name + " (ret)");
        foreach (ParameterInfo param in method.GetParameters()) { 
            Console.WriteLine("{0} {1}", param.ParameterType.Name, param.Name);
        }
    
    0 讨论(0)
提交回复
热议问题