How do I check for inheritance?

How can I check if there are any classes attached to an GameObject that inherit from a particular class?
Ie: Check if a GameObject has a concrete class that inherits from the abstract GunBase and if so, call the Fire() function of the concrete class.

I tried:

_gun = GetComponent<GunBase>();

But then i can only access functions of the abstract class and not the concrete.

Thanks

you can also type cast it.

 _gun = GetComponent<GunBase>() as ChildGun;

if(_gun != null)
{
     Debug.Log("We are a child of the GunBase class!");
}

when you use AS and the class cannot be typecasted it will be null.