Tab characters (\0x09) should not be used in code, and all indentation should be done with 4 space characters. Set the Visual Studio IDE default to 4 spaces for tabs if the defaults have been changed.
• Indent block contents below an open brace
• Indent select (VB.NET) or switch (C#) contents
• Indent case labels
switch (cIDDS.Tables[0].Rows[0][3].ToString().Trim())
{
case "Dr.":
this.ddlPrefix.SelectedIndex = 1;
break;
case "Mr.":
this.ddlPrefix.SelectedIndex = 2;
break;
case "Mrs.":
this.ddlPrefix.SelectedIndex = 3;
break;
case "Ms.":
this.ddlPrefix.SelectedIndex = 4;
break;
default:
this.ddlPrefix.SelectedIndex = 0;
break;
}//switch (cIDDS.usp_GetClientsByID[i].Prefix.ToString())
New lines and braces• Place “else” on a new line
• Place “catch” on a new line
• Place “finally” on a new line
• Place open brace on new line for C# types
• Place open brace on new line for C# methods
• Place open brace on new lines for C# anonymous methods
• Place open brace on new lines for C# control blocks (e.g.; for, if)
public void GetClientByLastName(out DataSet cDS, string lastName)
{
//---------------------------------------------------------------------
///
/// Description: Get Client by last name to populate search grid
///
///
last name for search
///
DataSet
//---------------------------------------------------------------------
//Set up dataset
DataSet ds = new DataSet();
try
{
//Make call to DAL to fill dataset with last name as parameter
domainDAL.GetClientByLastName(out ds, lastName);
}//try
catch (Exception ex)
{
//User message standard subject to change since may come from
//a resource file with standard canned messages
this.UserMessage = "An error occurred accessing the ARTS database by client last name.";
//domainDAL.DBMessage added to error
if (domainDAL.DBMessage != "")
{
string errorMessage = ex.Message.ToString();
//Logic for logging error to exception handling web service or Performance Monitor
}
}//catch (Exception ex)
cDS = ds;
}//public void GetClientByLastName(out DataSet cDS, string lastName)