Let’s face it, most coding standards are arbitrary. The key to a successful project, however, is not which standards you follow, but that you are consistent.
Here is a partial list of the C# coding standards my team uses and advocates. Most of these are industry-wide conventions and thus using them will ensure that your code is easily readable by people who are not you. (Many thanks to Adam for letting me post this here)
👍 use PascalCasing for class names and method names.
public class ClientActivity
{
public void ClearStatistics()
{
//...
}
public void CalculateStatistics()
{
//...
}
}
Why: consistent with the Microsoft’s .NET Framework and easy to read.
👍 use camelCasing for method arguments and local variables.
public class UserLog
{
public void Add(LogEvent logEvent)
{
var itemCount = logEvent.Items.Count;
// ...
}
}
Why: consistent with the Microsoft’s .NET Framework and easy to read.
Continue reading →