Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I split a comma-separated string?

Tags:

vb.net

I have a comma-separated string. For example,

{"one,two,three"}

Can I create an array from this and if so, how? In VB.NET.

like image 972
Ozair Wani Avatar asked Aug 23 '26 15:08

Ozair Wani


1 Answers

    ' you want to split this input string
    Dim s As String = "one,two,three"

    ' Split string based on comma
    Dim words As String() = s.Split(New Char() {","c})

    ' Use For Each loop over words and display them

    Dim word As String
    For Each word In words
        Console.WriteLine(word)
    Next
like image 150
Abbas Galiyakotwala Avatar answered Aug 25 '26 08:08

Abbas Galiyakotwala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!