Hi, I'm really really new to c# but have some experience with fortran.
I've been searching for the best way to read numeric data from a text file but after days of searching I can only see how to read in strings from the file.
Is there a way I can read in decimal values directly (delimited by spaces)???
AlanPosted Aug 8, 2007, 10:58 AM
The problem is that the binary representation of a decimal is completely different to its text representation. They always require exactly 16 bytes of storage however long or short they may be.
So all you can really do here is to read in each line of text using a StringReader(), use the string.Split(' ') method to split the line up, using the space delimiter, into a string array and then use decimal.Parse (or TryParse if there's a possibility of rogue data) to convert each element to a decimal.