Unreachable code detected in case statement
- by alex
I have a code:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (keyData)
{
case Keys.Alt|Keys.D1:
if (this._condition1)
{
return true;
}
else
{
return base.ProcessCmdKey(ref msg, keyData);
}
break;
case Keys.Control |Keys.U:
if (this._condition2)
{
return true;
}
else
{
return base.ProcessCmdKey(ref msg, keyData);
}
break;
default:
return base.ProcessCmdKey(ref msg, keyData);
}
return true;
It gives me "unreachable code detected" warning on breaks.
Is it good practice not to use break operator here ? I don't want to turn off "unreachable code detected" warning.
PS: There are many case in my ProcessCmdKey method.