J
Jon Skeet [C# MVP]
VMI said:I normally use the following sequence of code to read from a file. Is there
any other way I can do it where I don't have to do that first ReadLine()
that's outside of the loop? But if I don't do that, how am I going to
process that first line?
myReader.Open();
myVar = myReader.ReadLine(); //for first line of file
while (myVar != null)
{
/* do what I have to do with myVar */
myVar = myReader.ReadLine();
}
My normal code is something like:
string line;
while ( (line=myReader.ReadLine()) != null)
{
// Do something with line
}