17,740
社区成员
发帖
与我相关
我的任务
分享
public static void ChildMethod()
{
//我想在此显示调用本函数(Child)的父函数(Parent)中参数name的值(str)
//我现在能够得到的只有parent中的参数名字,却不知道如何得到值
////System.Diagnostics.StackFrame stack = new System.Diagnostics.StackFrame(1);
////System.Reflection.MethodBase methodBase = stack.GetMethod();
////ParameterInfo[] paramerters = methodBase.GetParameters();
System.Diagnostics.StackTrace myTrace = new System.Diagnostics.StackTrace();
System.IntPtr mh = myTrace.GetFrame(1).GetMethod().MethodHandle.Value;
for (int iCount = 1; iCount < myTrace.FrameCount; iCount++)
{
System.Reflection.MethodBase m = myTrace.GetFrame(iCount).GetMethod();
Console.WriteLine(m.MethodHandle.Value.ToString());
}
Console.ReadLine();
}