Question

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

String format:

ABC;PQR;XYZ

Was it helpful?

Solution

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.

OTHER TIPS

    Const XHundred = ",C,CC,CCC,CD,D,DC,DCC,DCCC,CM"
    Const Xten = ",X,XX,XXX,XL,L,LX,LXX,LXXX,XC"
    Const Xone= ",I,II,III,IV,V,VI,VII,VIII,IX"

I used this in a function. then later at the end of the function I used split() to split these into string arrays.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top