Do write only one statement/declaration per line
// correct
DateTime startDate;
DateTime endDate;
string name = "";
// avoid
DateTime startDate, endDate; string name = "";
Do use 4 spaces for indentatation. Do not use tabs.
Note: in Visual Studio or other IDEs, there is usually an option to automatically convert tabs into spaces.
if (num > max)
{
num = max;
}
Do insert a space in between variables, keywords, operators, etc
// correct
while (currentIndex <= maxIndex)
{
}
// avoid
while(currentIndex<=maxIndex)
{
}
Do use parentheses to make clauses in an expression apparent
if (true)
{
// expression here
}