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