[C#] UI.Text array

Hello everyones !
I’m creating a menu but i have a problem, I’m trying to create a Text array for my credits screen but I don’t know how to create/using it.
So far I have tried those lines of code :

        Names = new Text[6];
        Names[0] = Names[0].getComponent<Text>();

This simply doesn’t work and print an error :
-NullReferenceException: Object reference not set to an instance of an object.

        Names = new Text[6];
        Names[0] = (Text)this.GetComponent(typeof(Text));

And this one just empty my array of Text in the inspector of my object when i launch it…
I don’t really understand why neither of these two small code don’t work.

you are trying to get the Text component attached to a Text component… which makes no sense. Text[×] is a text component, it doesn’t have one attached to it.

edit: if you are trying to get all the Text components attached to a canvas you really should be using

GetComponentsInChildren<Text>();

from the canvas (note the s in GetComponent__s,__ GetComponent will only return the first one it finds, GetComponents returns all of them as an array)

Thanx for the quick response dude !
I have tried what you said and it return everythings that’s in the canvas, how do I sort all of these UI objects ?