C# Coding Standards and Naming Conventions
1. use PascalCasing for class names and method names.
public Class TestClass
{
public void TestMethod()
{
//--------------
}
}
2 use camelCasing for method arguments and local variables.
public Class TestClass
{
public void TestMethod(UserDetail userDetail)
{
int usersCount=userDetail.items.count
//-----
}
}
3. use PascalCasing for abbreviations 3 characters or more (2 chars are both uppercase)
HtmlHelper htmlHelper;
FtpTransfer ftpTransfer;
UIControl uiControl;
Why: consistent with the Microsoft's .NET Framework. Caps would grap visually too much attention.
4. use predefined type names instead of system type names like Int16, Single, UInt64, etc
// Correct
string firstName;
int lastIndex;
bool isSaved;
// Avoid
String firstName;
Int32 lastIndex;
Boolean isSaved;
5. use noun or noun phrases to name a class.
public class Employee
{
}
public class BusinessLocation
{
}
public class DocumentCollection
{
}
6. vertically align curly brackets.
// Correct
class Program
{
static void Main(string[] args)
{
}
}
public Class TestClass
{
public void TestMethod()
{
//--------------
}
}
2 use camelCasing for method arguments and local variables.
public Class TestClass
{
public void TestMethod(UserDetail userDetail)
{
int usersCount=userDetail.items.count
//-----
}
}
3. use PascalCasing for abbreviations 3 characters or more (2 chars are both uppercase)
HtmlHelper htmlHelper;
FtpTransfer ftpTransfer;
UIControl uiControl;
Why: consistent with the Microsoft's .NET Framework. Caps would grap visually too much attention.
4. use predefined type names instead of system type names like Int16, Single, UInt64, etc
// Correct
string firstName;
int lastIndex;
bool isSaved;
// Avoid
String firstName;
Int32 lastIndex;
Boolean isSaved;
5. use noun or noun phrases to name a class.
public class Employee
{
}
public class BusinessLocation
{
}
public class DocumentCollection
{
}
6. vertically align curly brackets.
// Correct
class Program
{
static void Main(string[] args)
{
}
}
Comments
Post a Comment