dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VBNET
Expertise: beginner
Jan 5, 2002

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Iterating over the characters in a string

Visual Basic .NET strings support the For Each statement, so you can iterate over each individual character as follows:

Dim s As String = "ABCDE"
Dim c As Char
For Each c In s
    Console.Write(c & ".")       ' => A.B.C.D.E.
Next
However, you should bear in mind that For Each loops on string characters aren't optimized. The following solution, that uses the Chars property, is 2-5 times faster:

Dim i As Integer
For i = 0 To s.Length - 1
    Console.Write(s.Chars(i) & ".")       ' => A.B.C.D.E.
Next
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date