How to disable any type of component?

I have a canvas with multiple game objects and I need to disable all the children of one of them, no matter what type it is (Image, text, or game object). I can’t use “.SetActive(false)” because it only works for game objects or “.enabled = false” because that doesn’t seem to work for game objects. Is there any way to disable something without it’s type mattering?

GameObject gobj = canvasSpeakers[g].speaker;
            for (int i = 0; i < gobj.transform.childCount; i++)
            {
                //None of these work
                gobj.transform.GetChild(i).enabled = false;
                gobj.transform.GetChild(i).SetActive = false;
            }

This code disables any element whether they are a game object or otherwise

GameObject gobj = canvasSpeakers[g].speaker;
for (int i = 0; i < gobj.transform.childCount; i++)
{
   gobj.transform.GetChild(i).gameObject.SetActive(false);
}

I think this will wok:

if (gobj is Component)
{
gobj.transform.GetChild(i).enabled = false;
}
else if (gobj is GameObject)
{
gobj.transform.GetChild(i).SetActive = false;
}