如何在c#中将字符串行转换为修复大小数组? [英] How to convert string line into fix size array in c#?
本文介绍了如何在c#中将字符串行转换为修复大小数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在c#中读取.txt文件。我有一个问题,如我的txt文件包含超过2000行,它将需要大量的时间来执行,因为目前我逐行读取并使用子字符串函数进行拆分数据。每行包含一个员工详细信息。在行中我将数据输入修复位置,例如,
Hi all,
I am reading .txt file in c#. I have one problem like my txt file contain more then 2000 lines and it will take lots of time to execute because currently i am read line by line and use sub-string function for split data. Each line contain one employee detail. In line i get data into fix position like,
Employee Name = 0 to 50 Character,
Employee Address = 51 to 200 Character,
Employee BDate = 201 to 215 Character,
Employee Gender = 216 to 220 Character
etc..
有没有读取线并使用此字段将其拆分为数组或其他内容的技术?我想提高性能。
Is there any technique to read line and split it to array or something else with this field? I want to improve performance.
推荐答案
是的,好像你正在寻找这个 http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser(v = VS。 110).aspx [ TextFieldParser ]
它支持固定字段而不必自己子字符串
Yes it seems you're looking for this one http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser(v=vs.110).aspx[TextFieldParser]
it support fixed with fields without having to substring it yourself
这篇关于如何在c#中将字符串行转换为修复大小数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文