如何将csv字符串转换为vb.net中的列表?

时间:2011-04-08 17:02:28

标签: vb.net csv

  

可能重复:
  Parse Delimited CSV in .NET

您好,

如何将csv字符串转换为vb.net中的列表?

3 个答案:

答案 0 :(得分:11)

你想要这样的东西......

Dim MyString as String = "one,two,three,four,five"
Dim MyArray() as String = Mystring.Split(",")
Dim MyList as List(Of String) = MyArray.ToList()

希望这有帮助!

答案 1 :(得分:3)

使用Linq:

Dim parts As String = "1,2,3,4"
Dim itemsList As List(Of String)

itemsList = (From s In parts.Split(",")
            Select s).ToList()

为您提供包含4个项目的列表

答案 2 :(得分:0)

看看分割功能。

    Dim a As String
    a = "data1,2,3,4,5"

    Dim b() As String
    b = a.Split(",")

    Dim c As List(Of String)
    c = b.ToList()

c将是一个字符串列表