I have this code in my form_load method...
System.IO.StreamReader file = new System.IO.StreamReader(serverList);
Servers = new List<Server>();
String line;
//while ((line = file.ReadLine()) != null)
while (! file.EndOfStream)
{
line = file.ReadLine().Trim();
if (line[0] != '#' && line != "")
{
Servers.Add(new Server() { ServerName = line.Split('|')[0],
IPorHostname = line.Split('|')[1] });
}
else
{
MessageBox.Show("I don't understand what the debugger is doing! Is this a bug?");
}
}
I wanted to be able to ignore empty lines in the file I was reading from, so I added the line != ""
bit and trimmed the line before checking it in the if statement. When loading the application the server list would be empty. So I switched into debug mode and step into this code. When line
is empty and I press F11 on the if statement, the debugging/stepping stops and the application shows. What I expect to happen is to go back around the while loop but that doesn't happen.
I added an else, with a message box as a test... The message box doesn't show!
In short, when line
is empty neither the true nor false code is executed, and the debugger stops stepping through the code.
What's happening here? Am I missing something obvious or is this a bug in Visual Studio?