## Naming Conventions

Qualified names can be broken after a dot . if they are too long for a single line, as shown in the following example.

## Layout Conventions

• four-character indents, tabs saved as spaces
• Write only one statement per line.
• Write only one declaration per line.
• If continuation lines are not indented automatically, indent them one tab stop (four spaces).
• Add at least one blank line between method definitions and property definitions.
• Use parentheses to make clauses in an expression apparent, as shown in the following code.
• if ((val1 > val2) && (val1 > val3))

## Commenting Conventions

• Place the comment on a separate line, not at the end of a line of code.
• Begin comment text with an uppercase letter.
• End comment text with a period.
• Insert one space between the comment delimiter // and the comment text
• Do not create formatted blocks of asterisks around comments.

## Language Guidelines

• Use string interpolation to concatenate short strings, as shown in the following code.
• string displayName = \$"{nameList[n].LastName}, {nameList[n].FirstName}";
• To append strings in loops, especially when you are working with large amounts of text, use a StringBuilder object.

## Implicitly Typed Local Variables

• Use implicit typing for local variables when the type of the variable is obvious from the right side of the assignment, or when the precise type is not important.
• Do not use var when the type is not apparent from the right side of the assignment.
• A variable type is considered clear if it’s a new operator or an explicit cast.
• Use implicit typing to determine the type of the loop variable in for loops.
• Do not use implicit typing to determine the type of the loop variable in foreach loops.

## Arrays

Use the concise syntax when you initialize arrays on the declaration line.

## Delegates

Simplify your code by using the C# using statement

## && and || Operators

• To avoid exceptions and increase performance by skipping unnecessary comparisons, use && instead of & and || instead of | when you perform comparisons
• The && operator short circuits when the first expression is false
• The & operator evaluates both, and causes a run-time error when divisor is 0.

## New Operator

• Use var in when using new: var instance1 = new ExampleClass();
• Use object initializers to simplify object creation.
• var instance3 = new ExampleClass { Name = "Desktop", ID = 37414, Location = "Redmond", Age = 2.3 };

## Event Handling

• If you are defining an event handler that you do not need to remove later, use a lambda expression.

## Static Members

• Call static members by using the class name: ClassName.StaticMember
• This practice makes code more readable by making static access clear.
• Do not qualify a static member defined in a base class with the name of a derived class.

## LINQ Queries

• Use meaningful names for query variables.
• Use aliases to make sure that property names of anonymous types using Pascal casing.
• Use implicit typing in the declaration of query variables and range variables.
• Align query clauses under the from clause, as shown in the previous examples.
• Use multiple from clauses instead of a join clause to access inner collections.