<分区>
通常我可以调用 this.GetType(),但我不能在静态方法中访问它。我们如何检查它?
标签 c# .net reflection static
<分区>
通常我可以调用 this.GetType(),但我不能在静态方法中访问它。我们如何检查它?
最佳答案
new StackFrame().GetMethod().DeclaringType
或
MethodBase.GetCurrentMethod().DeclaringType
或
new StackTrace(true).GetFrame(<frame index>).GetMethod() //e.g. <frame index> = 0
关于c# - 如何在静态方法中获取当前类的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9326278/