I want to something as simple as turning "this is a test"
into
new string[] {"t","h","i","s"," ","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.
Using StringBufferCreate an empty String Buffer object. Traverse through the elements of the String array using loop. In the loop, append each element of the array to the StringBuffer object using the append() method. Finally convert the StringBuffer object to string using the toString() method.
Answer: You just have to pass (“”) in the regEx section of the Java Split() method. This will split the entire String into individual characters.
I believe this is what you're looking for:
char[] characters = "this is a test".ToCharArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With