Are there any suggestions for developing a C# coding standards / best practices document?

We start with

  • Microsoft's .NET guidelines: http://msdn.microsoft.com/en-us/library/ms229042.aspx (link updated for .NET 4.5)
  • Microsoft's C# guidelines: http://blogs.msdn.com/brada/articles/361363.aspx.

and then document the differences from and additions to that baseline.


IDesign has a C# coding standards document that is commonly used. Also see the Framework Design Guidelines 2nd Ed.


Ironically setting the actual standards are likely to be the easy part.

My first suggestion would be to elicit suggestions from the other engineers about what they feel should be covered, and what guidelines they feel are important. Enforcing any kind of guidelines requires a degree of buy-in from people. If you suddenly drop a document on them that specifies how to write code you'll encounter resistance, whether you're the most junior or senior guy.

After you have a set of proposals then send them out to the team for feedback and review. Again, get people to all buy into them.

There may already be informal coding practices that are adopted (e.g prefixing member variables, camelcase function names). If this exists, and most code conforms to it, then it will pay to formalize its use. Adopting a contrary standard is going to cause more grief than it's worth, even if it's something generally recommended.

It's also worth considering refactoring existing code to meet the new coding-standards. This can seem like a waste of time, but having code that does not meet the standards can be counter-productive as you will have a mish-mash of different styles. It also leaves people in a dilemma whether code in a certain module should conform to the new standard or follow the existing code style.