How do I split a comma separated string?

后端 未结 2 642
耶瑟儿~
耶瑟儿~ 2021-01-23 11:47

I have a comma separated string.

e.g. {\"one,two,three\"} 

Can anyone please tell me if I can create an array from this and if so, how? in VB.

相关标签:
2条回答
  •     ' 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
    
    0 讨论(0)
  • 2021-01-23 12:29

    Like this:

    dim str as string = "one,two,three"
    dim str2() as string = split(str, ",")
    

    Reference:

    • Split Function (Visual Basic)
    0 讨论(0)
提交回复
热议问题