This chapter deals with the basic issue of iteration (looping) and flow control in C#.
Like Java
In C#, the while (in while loops), do and while (in do...while loops), and for (in for loops) keywords work in exactly the same way as in Java.
You can break and continue from within loops to terminate iteration prematurely (except that you cannot use them with labels).
Unlike Java
Flow control in C# is very much the same as Java, except for:
a new and useful foreach keyword;
some changes to how switch-case is used;
C# retains the goto keyword; [1]
[1] goto is a reserved word in Java, but has no functionality. The usage of goto in C/C++ has often been criticized as poor structural programming. Use it with care in C#.
you cannot use break and continue with labels.
Short examples are given showing while/do...while/for loops and the use of continue and break, but they will not be described in detail because they are used the same way in Java. The later sections emphasize the new stuff that came with C#.
18.117.186.46