Tuesday, September 23, 2008

Iterating through a string

'String.GetEnumerator Method
'Retrieves an object that can iterate
'through the individual characters in the string


Dim mystring As String = "Madness123"

Dim myCharEnumerator As CharEnumerator

myCharEnumerator = mystring.GetEnumerator()

While myCharEnumerator.MoveNext
Console.WriteLine(myCharEnumerator.Current.ToString())
End While



'Will display...

'M
'a
'd
'n
'e
's
's
'1
'2
'3


Console.ReadLine()

No comments: