如何在抽象类的静态方法中获取当前类的类型(不是名称字符串,而是类型本身)?在静态方法中获取运行时的当前类?
using System.Reflection; // I'll need it, right?
public abstract class AbstractClass {
private static void Method() {
// I want to get CurrentClass type here
}
}
public class CurrentClass : AbstractClass {
public void DoStuff() {
Method(); // Here I'm calling it
}
}
这个问题很类似这样的:
How to get the current class name at runtime?
不过,我想从静态方法中获取这些信息。
看看这个静态方法:[中的GetType静态方法(http://stackoverflow.com/questions/7839691/gettype-静态方法) – Zbigniew 2013-04-20 13:15:44