Let’s say I have a string like this.
Dim str As String = "code"
I need to break this string down to an array of characters like this,
{"c", "o", "d", "e"}
How can I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Every string is an implicit char-array. So you can get the 3rd char by:
Edit: Just for the sake of completeness. You can also use
String.ToCharArrayto convert the string instance to a newchar-arrayinstance. The core benefit of usingToCharArrayis that the char-array you receive is mutable, meaning you can actually change each individual character.Note that you could also use
LINQ. If you for example want the first three characters of a String: