标签:
参考网址:http://stackoverflow.com/questions/429552/can-i-get-the-signature-of-a-c-sharp-delegate-by-its-type
1、我的测试代码:
namespace RefTest01 { [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void D_Test01(int _i); // *** public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) {/* if (FfnTest01 == null) MessageBox.Show("FfnTest01 == null"); else FfnTest01(3); //*/ Type delegateType = typeof(D_Test01); 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); } } } }
打印信息:
Void (ret)
Int32 _i
2、
3、
标签:
原文地址:http://www.cnblogs.com/csskill/p/5553400.html