Coloring separate text in string array

I was thinking of possibilities to color separate text chunks inside a string array.
One way could be rendering the whole string array by single char, by encoding text color parameters inside string itself, in hexadecimal or other.

string someArray[10];
string text = "Hi,[] how are you[Color.white]";

someArray[0] = text;

Then write special algorithm which reads array element string by single char and only then assign correct colors on the go, and only then renders. But this most likely won’t be the best optimized way to do this.

So this pretty much the question, maybe there are already such built in methods which can create/handle something like this. Or, maybe string array is not the best approach for such “complicated” things, and completely different method should be used instead.

I know i could pretty easy achieve this if i would use simple label, and just render the text using hex and /n, so it would look like chat, but by this it’s not that easy to control max text messages and turn string array in infinite loop cycle, so you could have string in size of 400 and it would rewrite first messages when max message count has been reached.

The idea is about creating chat system.

If you’re looking for better performance, you could split your text to an array of strings, one for each word (or even more than one word), and also have an adjacent array of the same size, of colors, so that colors would represent the color of the text in strings*.*
Then when you render the text, render each string from the array with the correct color according to the matching cell in the colors array.