Blindy Blindy - 10 months ago 68
C# Question

Possible mistaken empty statement – compiler is mistaken in this case

I feel so silly asking this, but how do I instruct the compiler that it is not a mistake? I really intend to have an "empty" branch in my

statement, with a clear
at the end catching the bad values.

I can of course restructure the whole
around this, but it'll be less clear as a result, and working around a silly compiler warning seems weird. Also I'd prefer if I didn't have to disable the entire warning, just for this specific statement.

Answer Source

Well I knew it was something silly, simply using an empty block gets rid of it:

  // code here
else if(condition2)
  // code here
else if(condition3)
    //nothing to do
  // error case here