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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5598407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:26:02  来源:igfitidea点击:

How to convert csv string to list in vb.net?

vb.netcsv

提问by chobo

Possible Duplicate:
Parse Delimited CSV in .NET

可能的重复:
在 .NET 中解析分隔的 CSV

Hi,

你好,

How can I convert a csv string into a list in vb.net?

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

回答by DWRoelands

You want something like this...

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

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

Hope this helps!

希望这可以帮助!

回答by thorkia

using Linq:

使用 Linq:

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

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

Gives you a list with 4 items

给你一个包含 4 个项目的列表

回答by Angelom

Take a look at the split function.

看看split函数。

    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 will be a list of strings

c 将是一个字符串列表