学习笔记(二)C#获取当前正在执行的代码的命名空间、类、方法的名称

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huaxiyuan/article/details/52677889

静态:

命名空间+类:System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName 

命名空间:System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Namespace

类:System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name

方法:new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name


非静态:

命名空间:this.GetType().ToString()

类:this.GetType().Name

方法:new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name


猜你喜欢

转载自blog.csdn.net/huaxiyuan/article/details/52677889