I'm getting strange results testing the return value from a function. This code is inside a for loop:
DialogResult result = EvalReturnFromWS(returnMsg);
switch (result)
{
case DialogResult.Yes:
case DialogResult.No:
continue;
default:
break;
}
Here is a snippet from the called function (in my unit testing I always click the "yes" button):
DialogResult result = MessageBox.Show(mbText.ToString(), caption, button, icon);
switch (result)
{
case DialogResult.Yes:
return DialogResult.Yes;
case DialogResult.No:
return DialogResult.No;
case DialogResult.Cancel:
return DialogResult.Cancel;
}
When I click "Yes" it returns DialogResult.Yes but back in the calling code, execution flows to the 2nd case which is "no" and this does a continue which is what I do NOT intend.
Elsewhere on StackOverflow, I saw a thread that suggesting coding a "fall-through" case like I have for DialogResult.Yes would serve to fall through.
In short, if YES, I want to resume execution with the next statement after the end of the switch case(s). That is, "fall through".
EDIT - sorry for confusion. Yes, the top snippet is inside a for loop. The 2nd snippet is inside the called function (that code issues MessageBox.Show).