[C#]
I have classes:
public class ChildClass: ParentClass {
// ...
}
public class ParentClass {
public GetClassName() {
// ...
}
}
And code:
var obj = new ChildClass();
string className = obj.GetClassName(); // <---- Here I want to get "ChildClass"
I know it may be done using Reflection. But I dont know how. Help me please.
string className = obj.GetType().FullName;
如果要在父类的方法中执行此操作,请执行以下操作:
string className = GetType().FullName;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.