I was going through Bob Tabors C# instructional videos, which is fantastic btw. Anyway, I'm a little confused with this one. On the following code, within the while loop, there is an if (line != null) statement . Why is this statement necessary? Doesn't the While loop set the same condition? I tried it without the if (line != null) statement, and it produces a blank window when the program is run. Any help would be appreciated.
Here is the source code --
staticvoid Main(string args)
StreamReader myReader = newStreamReader("Values.txt");
string line = "";
while (line != null)
line = myReader.ReadLine();
if (line != null) //why is this necessary? This sets the same condition specified on the while loop.