Statement-Level Comments in C#

What about statement-level comments? How should you handle those?

In general, avoid statement-level comments. One exception may be when you need to explain what a variable or argument does.

Statement-level comments are those that are on the same line and to the right of code.


// Incorrect.
while ( doc.Read() )     // Read all records.

// Correct.
// Read all records.
while ( doc.Read() )

// Correct.
string inputFile;       // Input file.
string outputFile;      // Output file.

// Correct.
void LoginWith(var userName,    // User's username.
    var password                // User's password.

Leave a Reply

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

You are commenting using your 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