Hi, I have a sample program structure in C++ as shown in the image link above. Anybody could suggest me a way to rewrite that structure into an equivalent in C# ?

As you can see from the picture, the C++ code use "goto" statement to jump around but I would not want to do the same in C#, I would want to avoid those "goto"s.

In fact:

1. I can't simply rewrite using the same "goto" as in C#, goto has more limited scope than in C++. It is not allowed to jump from a code block into another block in C# like we normally do in C++. in C#, label has its scope only in the code block that it's declared.

2. I find it hard to use switch or probably try/catch/finally since the original code uses goto to jump from outter code block to inner code block or vice versa. All those variables declared in the outter code block will not be visible to the inner one so the compiler will complain.

Anybody encounter this before, could suggest me a best practice to archive the same thing in C# ?

The worse case is that I may need to rewrite duplicate code to avoid "goto" ?

Thanks and pardon my English. English is not my native language.

Alex To