如何拆分逗号分隔的字符串? [英] How do I split a comma separated string?

查看:64
本文介绍了如何拆分逗号分隔的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个逗号分隔的字符串.

I have a comma separated string.

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

谁能告诉我我是否可以从中创建一个数组,如果可以,如何创建?在 VB.net 中.

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

推荐答案

    ' 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

这篇关于如何拆分逗号分隔的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆