Ad

How To Split A String Into Array Based On Delimitter In VB.Net

- 1 answer

How can I assign a split parts of a string into an array list directly ?

String format:

ABC;PQR;XYZ

Ad

Answer

Not sure what you want but doesn’t the following serve your purpose?

Dim input As String = "ABC;PQR;XYZ"
Dim x As New List(Of String)(input.Split(";"c))

Notice that I’ve used the superior List<String> (from System.Collections.Generic) instead of the deprecated ArrayList.

Also, do you really need a modifiable List? Unless you want to add or remove entries, a plain array should be fine.

Ad
source: stackoverflow.com
Ad