Thursday, July 9, 2009

C# - Reading .dat file data into an array?

I have a problem trying to read a segment of data from a file into an array using C#.





For example, the file contains ONLY 1 LINE with data:





AS0001 C40000 C40002 ...etc





Each segment is separated by some "whitespace", something 2-5 white spaces.





How can I grab each segment and put them into an array? Eg.





buffer[0] = AS0001


buffer[1] = C40000


....


...etc





Anyone with any ideas? Thanks!

C# - Reading .dat file data into an array?
read in the entire line then parse out what you want with the white space. Using built in functions. They are putting the white space there for the exact purpose you are trying to achieve. Sometimes there will use coma's. But read the entire line, then while its not a space, put the characters into the array[i], then when you get a space, do an i++ and move to next word,


No comments:

Post a Comment