How get a name of child-class in a body of parent-class
[C#]
I have classes:
public class ChildClass: ParentClass {
// ...
}
public class ParentClass {
public GetClassName() {
// ...
}
}
And code:
var obj = n开发者_如何学Goew 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;
If you are doing this in a method on the parent class, just do:
string className = GetType().FullName;
精彩评论