Code Structure and Formatting

When writing methods we should be careful to do correct indentation (moving blocks of the code to the right).

Example for correctly formatted C# code:

Example for incorrectly formatted C# code:

When the title line of the method is too long, it is recommended to divide it into several lines, as each line after the first is two tabulations to the right of the first (for better readability):

Another good practice when writing code is to leave an empty row between the methods, after loops and conditional statements. Also try to abstain from writing long lines and complicated expressions. In time you will see that this makes the readability better and saves time.

It is also recommended to always use cirly brackets for the bodies of conditional statements and loops. The brackets not only improve readability, but also reduce the possibility to make a mistake and the program to run incorrectly.

results matching ""

    No results matching ""