How can i convert string to array something like this ![]()
var text : String = "hello";
var array : String[] = ConvertToArray(text);
// array[0]="h" array[1]="e" array[2]="l" array[3]="l" array[0]="o"
How can i convert string to array something like this ![]()
var text : String = "hello";
var array : String[] = ConvertToArray(text);
// array[0]="h" array[1]="e" array[2]="l" array[3]="l" array[0]="o"
Did you mean:
array[4]="o"?
Also, may I ask why you need the string in array form?
A string is already an array; you don’t have to do anything:
var text = "hello";
print (text[0]);
–Eric
As Jesse pointed out, you can directly access the characters that way. If you still need it as a separate, independant array, you can use the String.Split or String.ToCharArray methods.