strings into arrays

spyter

New member
Joined
Dec 30, 2008
Messages
4
Programming Experience
Beginner
I am trying to put a string (variable) into an array where each character of the string is a new array var

for example:

if i have

Dim someString As String = "sometext"

Dim someArray As Array

I want to store the above 'sometext' into the array like this:

someArray[0] = s
someArray[1] = o
someArray[2] = m
someArray[3] = e
etc...

any help or advice would be greatly appreciated!! Im sure this is probably easy, but I am new to vb.net

thanks in advance!!!
 
String can be treated as Char arrays as they is:
VB.NET:
Dim first As Char = "hello"(0)
String class also has a ToCharArray method that can return the whole string as a Char array object.
VB.NET:
Dim all() As Char = "hello".ToCharArray
Array class is the base class for all arrays, but variables for array objects are rarely declared as this type. Instead you use some type that is common for the contained items and use () to denote an array of that type, like the example above. Array class has some useful shared methods and is normally only used explicitly in this context.
 
Back
Top