9.8. Summary

C# supports the following control flow constructs.

  • The if statement. The if, if-elseif, if-elseif-else, and if-else constructs are similar to those of Java. Note that unlike C++, C# and Java do not allow the expression to be evaluated to 1 or 0; the integer 1 does not stand for true, and 0 does not stand for false.

  • The while statement. Like the if statement, while loops can be nested. The while loop expression is an expression that can be implicitly converted to bool or to a type that contains overloading of the true and false operators.

  • The do while statement. The body loop of the do statement is executed at least once. The expression in the while part of the do while statement is an expression that can be implicitly converted ...

Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.