2 Answers 2
You're looking for ToCharArray().
This returns an array of chars.
If you really need an array of strings, you can write
Array.ConvertAll(s.ToCharArray(), c => c.ToString())
Yuriy Faktorovich
68.9k14 gold badges107 silver badges150 bronze badges
answered Jul 26, 2011 at 0:38
SLaks
891k182 gold badges1.9k silver badges2k bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Joper
I knew that there is method
s.ToCharArray() but didn't know how to convert it to string array just using just one line of code.If you'd like to convert it to an array of characters you can use
s.ToCharArray();
But note that it already implements IEnumerable<char> and has an indexer by position. If you really need strings
s.Select(c => c.ToString()).ToArray()
answered Jul 26, 2011 at 0:40
Yuriy Faktorovich
68.9k14 gold badges107 silver badges150 bronze badges
Comments
lang-cs