I want to create an array/list of strings of the Comma seperated strings (file extensions) that are entered in a Textbox.
For the following block of code:
Dim csv As String = Textbox1.Text + ',' While csv.IndexOf('.') <> -1 lstOfStrings.Add(csv.Substring(0, csv.IndexOf(','))) csv = csv.Remove(0, csv.IndexOf(',') + 1) End While
The output is:
Textbox1.Text = ‘.exe,.php’
listOfStrings = { ‘.exe’, ‘.php’ }
Is there a better way to write this code?
A better way would be to use the Split method: