.NET 中的 TextFieldParser 等效项? [英] TextFieldParser equivalent in .NET?

查看:38
本文介绍了.NET 中的 TextFieldParser 等效项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在与 VB6 中的 TextFieldParser 类等效的现代 .NET?性能比简单的 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 毫秒
  • Microsoft.VisualBasic.FileIO.TextFieldParser 平均时间:15843 毫秒
  • String.Split avg time: 291 ms
  • Microsoft.VisualBasic.FileIO.TextFieldParser avg time: 15843 ms

您可以使用 Microsoft.VisualBasic.FileIO.TextFieldParser 类.参考 Microsoft.VisualBasic.要点示例.

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

这篇关于.NET 中的 TextFieldParser 等效项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆