The focus of this document is on providing a reference for writing C#. It includes naming, structural and formatting conventions as well as best practices for writing clean, safe and maintainable code. Many of the best practices and conventions apply equally well to other languages.
The focus of this document is on providing a reference for writing C#. It includes naming, structural and formatting conventions as well as best practices for writing clean, safe and maintainable code.
Many of the best practices and conventions apply equally well to other languages.
This handbook has the following aims and guiding principles:
This handbook includes:
The recommended environment and tools at this time are:
For older versions of Visual Studio and C#, use what you can or refer to older versions of this handbook.
This document is a work-in-progress. Please speak up or contribute if you think there is something missing.
The handbook defines the goal. Use iterations and refactoring to incrementally bring the code closer to full compliance.
Fix non-conforming code at the earliest opportunity.
Modern IDEs generate code; this is very helpful and saves a lot of work. Within reason, the generated code should satisfy the coding guidelines. If the generated code is not under your control, then it's OK to turn a blind eye to style infractions.
This repository includes configuration files that set up the rules outlined in this handbook for StyleCop and ReSharper and EditorConfig.
base
this
nameof
var
out
variables
switch
continue
return
goto
unsafe
throw
-Expressions
checked