I had this code in a project in VS2010 – it was a placeholder method I hadn’t fully implemented yet. I started the implementation today. Notice there are no {} surrounding the if/else for the while statement. This compiled many times – it has been that way for quite some time. Is this a bug in VS? I thought loops all needed {}
private void ParsefCIPProfiles(string block)
{
StringReader reader = new StringReader(block);
string readline = reader.readline();
while (readline != null)
if ()
{}
else
{}
}
No, it isn’t a bug. In fact for single-statement contents, most other scoped statements also don’t require the curly braces. For instance: