Comment Position and Indentation

Problem
You want to know where to place comments and how they should be indented.

Solution
Comments should use the same indenting level as the code block it’s related to and immediately before it. There should be no blank lines in between.

Examples

// This is wrong. It's not indented and a blank line is used.
for ( int i = 0; i <= arr.Length; i++ )
{    
// Initialize the array element.

    arr[i] = i;
}

// This is correct.
for ( int i = 0; i <= arr.Length; i++ )
{
    // Initialize the array element.
    arr[i] = i;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s