Using GetComponentsInChildren for a List of text

I managed to get text display for a button hover for one of the ‘Text’ components that is a child of my gameObject.

I will like a second ‘Text’ that is also a child to be displayed the same way. Here is my code and where I think my errors are:

    Text[] nameLabel;

    private void Start()
    {
        if (nameLabel == null)
        {
        nameLabel = GetComponentsInChildren<Text>();
        }
    }

    public void ButtonHover()
    {
 
        foreach (Text label in nameLabel) // Not sure if this line is correct
        label.gameObject.SetActive(true);
        label.text = this.transform.name; // It cannot find label
    }

    public void ButtonExit()
    {
        label.gameObject.SetActive(false); // It cannot find label
    }
    }

You need braces { } around your foreach block.

You should probably spend a little time investing in your programming fundamentals before trying to tackle something like Unity.

Why would you post this in an Unity forum. You should probably not help people.

He’s trying. If you make a mistake like this, you’re very rookie on C#, it’s advisable to go back to the beginning and refresh/take up on the C# basics.

So in another words you guys are telling the world that no rookies can use Unity?

I think an advanced programmer would probably be writting their own game engine.

No one told you that you should not use Unity. We merely made a remark that you have to polish your C# knowledge.
But of course, you can choose to take offence and not develop yourself and continue making the same very rookie mistakes again and again. It’s up to you.

Oh and BTW, you’re welcome!

Well, you’re wrong.

Yeah Ninja, the message above before I commented ‘Why would you post this in an Unity forum. You should probably not help people.’ said not to use Unity. Which is now deleted. Is what I was getting at. I actually love learning the foundations of programming by using Unity and will like to continue to do so.

I don’t know, it’s a possibility that I missed a message, since you haven’t answered anyone, I thought you’re answering @GroZZleR message, which says

Which does not say you should not use Unity.

But I may be wrong. Although you do whatever you see fit, but when you come here, ask for help, you get the help, and you get the advise to polish your coding skills and instead of saying thank you, you’re attacking the people who help you. I don’t know, it does not seem right to me. But that’s just me. It’s your business, but it was the last time I took a look at your threads. That’s for sure.