Extensive commonality exists in the syntax and functionality of statements in C# and Java:

  • All statements must end with a semicolon.

  • Block statements are formed using braces.

  • An empty statement is represented by a single semicolon. In both languages, it’s considered a good idea to comment the existence of any empty statement.

Labeled Statements

Labeled statements are implemented by C# and Java in the same way, differing only in how jumps are performed. In Java, jumps are made to a labeled statement using the continue or break statement, as shown in the following example:

// statements
while (/* some condition */) {
    break mylabel;

In C#, the break and continue statements do not take targets. To jump to a labeled statement, use the ...

Get C# for Java Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.