110,533
社区成员
发帖
与我相关
我的任务
分享
public class A
{
public A()
{
DataSet ds = SqlHelper.ExecuteDataset(...);
}
}
Console.WriteLine("当前调用该方法的类名为:{0}", st.GetFrame(i + 1).GetMethod().ReflectedType.Name);
static void Main(string[] args)
{
A.AMethod();
}
class A
{
public static void AMethod()
{
StackTrace st = new StackTrace();
for (int i = 0; i < st.FrameCount; i++)
{
if (st.GetFrame(i).GetMethod() == MethodBase.GetCurrentMethod() && i != st.FrameCount - 1)
{
Console.WriteLine("当前调用该方法的方法名为:{0}", st.GetFrame(i + 1).GetMethod().Name);
break;
}
}
}
}
public class A
{
public A()
{
DataSet ds = SqlHelper.ExecuteDataset("A",...);
}
}