How to I find out if an class inherits from another type: class Dogs : List<Dog>
How to I find out if an class inherits from another type?
Example:
public class Dogs : List<Dog>
{
}
I want to check if Dogs inplements/inherits from IEnumerable.
Is there a way to do that through IClassDeclaration or IClass?
Please sign in to leave a comment.
You can use the TypeElementUtil.GetAllSuperTypes extension method on IClass (well, ITypeElement) to return a list of declared elements that represent the hierarchy. You can then examine each element, get its fully qualified name, etc, and check to see if it's what you're after.
Thank you. That worked great!