Spaces and Parentheses in C#

Problem
You want to know how to handle spaces when dealing with parentheses in C#.

Solution
Add one space after the opening parentheses and before the closing parentheses in if, while, for, foreach, switch, and lock statements.

Examples

// This is OK.
while (x == 0)
{
    Do something...
}

// This is better.
while ( x == 0 )
{
    Do something...
}

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 )

w

Connecting to %s