【发布时间】:2011-09-15 14:40:59
【问题描述】:
可能重复:
Reflection in C#: How do I get the calling method name and type?
假设我有两个类:
public class Foo {
public Foo() {
Bar.Pirate();
}
}
public static class Bar {
public static void Pirate() {
Type callingClassType = ...
}
}
在Pirate() 中,我如何获得调用Pirate() 的类(Foo)的Type?
【问题讨论】:
-
stackoverflow.com/questions/3095696/… 虽然,我认为查看堆栈跟踪是一个坏主意。
-
我很好奇你为什么想要这个功能。
标签: c# reflection