TextFieldParser在.NET中等效? [英] TextFieldParser equivalent in .NET?
本文介绍了TextFieldParser在.NET中等效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一个现代的.NET相当于VB6中的 TextFieldParser
类?性能比简单的 String.Split()
Is there a modern .NET equivalent to the TextFieldParser
class in VB6? Performance is a lot lower than a simple String.Split()
推荐答案
我已将该效果与该代码进行了比较: https://gist.github.com/Ruszrok/7861319
I have compared performance with that code: https://gist.github.com/Ruszrok/7861319
我使用了一个大约1 000 000条记录用空格分隔的输入文件。我尝试了五个实验。
I used an input file with about 1 000 000 records separated with spaces. I tried five experiments.
-
String.Split
平均时间: 291 ms
-
Microsoft.VisualBasic.FileIO.TextFieldParser
平均时间: 15843 ms
String.Split
avg time: 291 msMicrosoft.VisualBasic.FileIO.TextFieldParser
avg time: 15843 ms
您可以使用 Microsoft.VisualBasic.FileIO.TextFieldParser
类。参考 Microsoft.VisualBasic
。 gist中的示例。
You can use the Microsoft.VisualBasic.FileIO.TextFieldParser
class. Reference Microsoft.VisualBasic
. Sample in gist.
这篇关于TextFieldParser在.NET中等效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文