0

我在每个单词的末尾有一长串三个单词#都存储在一个文本文件中如何打印它直到文件中的#:Jorj# bush#123456#美国总统#我想要类似的东西:

Dim details() As String = IO.File.ReadAllLines(filename)
Dim query = From line In details
            Let fullname = line.Split("#"C)(0)
            Let family_name = line.Split("#"c)(1)
            Let phone_number = line.Split("#"c)(2)
            Let comment = line.Split("#"c)(3)   
            Select fullname, family_name, phone_number, comment
4

1 回答 1

2

这应该按预期工作。但是你可以让它更有效率:

Dim query = From line In details
            Let parts = line.Split("#"c)
            Let fullname = parts(0)
            Let family_name = parts(1)
            Let phone_number = parts(2)
            Let comment = parts(3)
            Select fullname, family_name, phone_number, comment

否则,您将每行拆分 4 次。

于 2013-01-07T16:25:04.050 回答