Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Braces and brackets

0.00/5 (No votes)
3 Nov 2000 19  
Options for placing braces

Options for Parentheses

Option 1: Spaces between inside and outside the parentheses. 

if ( something )
...

Option 2: Spaces outside parentheses, no space inside.

if (something)
...

Option 3: Spaces inside parentheses, no space outside.

if( something )
...

Option 4: No white space.

if(something)
...

Options for braces

Option 1: Braces starting on control line.

if (something) {
  // statements
}

Option 2: Braces starting on line under control line, non-indented.

if (something) 
{
    // statements
}

Option 3: Braces starting on line under control line, indented.

if (something) 
    {
    // statements
    }

Option 4: Braces starting on control line, closing brace indented.

if (something) {
    // statements
    }

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here