public static string GetMethodInfo()
{
string str = "";
str += "命名空间名:"+System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Namespace +"
";
str += "命名空间+类名:"+System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "
";
str += "类名:"+System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name+ "
";
str += "方法名:"+System.Reflection.MethodBase.GetCurrentMethod().Name + "
";
str += "
";
StackTrace ss = new StackTrace(true);
MethodBase mb = ss.GetFrame(1).GetMethod();
str += mb.DeclaringType.Namespace + "
";
str += mb.DeclaringType.Name + "
";
str += mb.DeclaringType.FullName + "
";
str += mb.Name + "
";
return str;
}
public static void Main()
{
Console.WriteLine(GetMethodInfo());
Console.ReadKey();
}