- Home /
Question by
Slayerkris · Oct 08, 2013 at 01:21 PM ·
string.split
String Split all characters?
Hello. I'm trying to make a scrolling text that shows individual letters/symbols with a small delay.
I was thinking about :
string[] characters = text.Split['*'];
but that does not seem to work. Is there anyway that I could split every character in a string?
Thanks,
Kris
Comment
How about
char[] characters = text.ToCharArray();
?
Could do scrolling chars directly from the string -- no need for another array. In other words, a string already is an array of single letters.
Just use that same text[i].ToString()
(or the more common ""+text[i]
) conversion right in the display loop.
Best Answer
Answer by MFen · Oct 08, 2013 at 01:33 PM
text = "ThisIsATest";
string[] characters = new string[text.Length];
for (int i = 0; i < text.Length; i++)
{
characters[i] = System.Convert.ToString(text[i]);
}
Alternatively, line 5 could be
characters[i] = text[i].ToString();