I'm fairly new to C# and I tried my best to find an already answered question similar to mine but I just could not get the answers to relate to my question.
So, I have an "Instance"-class which is supposed to be a super class for all game objects. It has a read-only ClassName property defined as such:
public string ClassName
{
get
{
return this.GetType().Name;
}
}
And my reason for this question is that I want to have the following method which would return true if the current object is an instance of className, or if the object's class inherits from className.
public bool IsA(string className)
{
//TODO
}
This needs to be sort-of "recursive" so that if the case was: X : Class1 : Class2: Class4 then X.IsA(Class4) would return true
I've looked into methods like object.GetType() but I haven't figured out a solution.
Any ideas?