TextFieldParser equivalent in .NET?

后端 未结 2 1876
故里飘歌
故里飘歌 2020-12-17 08:29

Is there a modern .NET equivalent to the TextFieldParser class in VB6? Performance is a lot lower than a simple String.Split()

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 08:46

    I have compared performance with that code: https://gist.github.com/Ruszrok/7861319

    I used an input file with about 1 000 000 records separated with spaces. I tried five experiments.

    • String.Split avg time: 291 ms
    • Microsoft.VisualBasic.FileIO.TextFieldParser avg time: 15843 ms

    You can use the Microsoft.VisualBasic.FileIO.TextFieldParser class. Reference Microsoft.VisualBasic. Sample in gist.

提交回复
热议问题