I get a strange result of the return value from a function. This code is inside the loop:
Dialog result result = EvalReturnFromWS (returnMsg); Switch (Result) {Case DialogResult.Yes: Case DialogResult.No. Continue; Default: Break; } This is a snippet from the function (I always click on the "yes" button in my unit test):
dialog result result = message Show box (mbText.ToString (), captions, buttons, icons); Switch (Result) {Case DialogResult.Yes: Return DialogResult.Yes; Case DialogResult.No: Return DialogResult.No; Case DialogResult.Cancel: Return DialogResult.Cancel; } When I click on "Yes", it returns DialogResult. Yes, but back in the calling code, the 2 digit execution flow which is "no" and continues what I do not intend.
Somewhere else on the stack overflow, I saw a thread called "Dialog Roustal "For my" Falling "case was suggesting coding.
In short, if yes, then after the end of the switch case (s) I want to resume execution with the next statement. That is, "fall through"
Edit - Sorry for the confusion Yes, the top snippet is inside a loop. The second snippet function (the issue of that code is inside the message box) show.
What do you want Do to do brakes; to the DialogRilt Yes is inserted in the case. You do not want to fall into this matter. switch (results) {case dialog result. Yes: break; // Skip the switch statement and the code case dialog continues to execute. NO .: Continue; // loop moves forward to the next default: break; // skip the statement statement and executing code} This means that the details of a case goes up to the next one. There is nothing to do with leaving the switch statement with its execution, in your example, under break under default: , from that block of code Breaks out (switch, no loop) and switch statement again, it does not break out of the external loop. The reason for this is that break; In the case of the switch there is a keyword that prevents the switch of the case block and execution. However, continue ; The loop will continue because it has not been used within any switch case. Try running this example code:
for (int i = 0; i i = 0 and i = 2 because it will only output 1 loop For the issue, i = 1 executes it for Console.Out.WriteLine (i); . Edit
> And, if you want to exit the loop from within your switch, then see this question: < / Html>
Comments
Post a Comment