mowwwalker mowwwalker -3 years ago 111
C# Question

Split string into string array of single characters

I want to something as simple as turning

"this is a test"

new string[] {"t","h","i","s"," ","a"," ","t","e","s","t"}

Would I really have to do something like

test = "this is a test".Select(x => x.ToString()).ToArray();

edit: To clarify, I don't want a char array, ideally I want an array of string. I don't really see anything wrong with the above code except for the fact that I would think there is an easier way.

Answer Source

I believe this is what you're looking for:

char[] characters = "this is a test".ToCharArray();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download