CSharp Coding Conventions
C# Coding Conventions

Namespace
DO use PascalCase for namespace
DO use “noun” for namespace
DO use “plural word” for namespace
DO use file-scoped namespace declaration if using C#10 or higher
DON’T use underscore for namespace
DON’T exceed 100 characters length for namespace name
Class
DO use PascalCase for class name
DO use “noun” for class name
DO use “singular word” for class name
DO vertically aligned curly brackets
DON’T use underscore for class name
DON’T exceed 100 characters length for class name
Interface
DO use PascalCase for interface name
DO use “noun” for interface name
DO prefix interface with the letter “I”
DO vertically aligned curly brackets
DON’T use underscore for interface name
DON’T exceed 100 characters length for interface name
Constant
DO use PascalCase for constant name
DO use “noun” for constant name
DO use meaningful words for constant name
DO use predefined type name (int, string, float) instead of .NET type (Int32, String, Single) for constant declarations
DON’T use underscore for constant name
DON’T use SCREAMINGCASE for constant name
DON’T use uncommon abbreviations for constant name
DON’T use Hungarian notation for constant name
DON’T exceed 50 characters length for constant name
Field
DO use camelCase for field name
DO use “noun” for field name
DO prefix fields with the underscore symbol
DO use meaningful words for field name
DO use predefined type name (int, string, float) instead of .NET type (Int32, String, Single) for field declarations
DO make field as readonly if possible
DON’T use uncommon abbreviations for field name
DON’T use Hungarian notation for field name
DON’T exceed 50 characters length for field name
Property
DO use PascalCase for property name
DO use “noun” for property name
DO use meaningful words for property name
DO use predefined type name (int, string, float) instead of .NET type (Int32, String, Single) for property declarations
DON’T use uncommon abbreviations for property name
DON’T use Hungarian notation for property name
DON’T exceed 50 characters length for property name
Method
DO use PascalCase for method name
DO use “verb” for method name
DO vertically aligned curly brackets
DON’T use underscore for method name
DON’T exceed 50 characters length for method name
Method Arguments
DO use camelCase for method arguments
DO use “noun” for method arguments
DO use predefined type name (int, string, float) instead of .NET types (Int32, String, Single) for method arguments
DON’T use uncommon abbreviations for method arguments
DON’T use Hungarian notation for method arguments
DON’T use underscore for method arguments
DON’T exceed 50 characters length for method arguments
Local Variables
DO use camelCase for variable name
DO use “noun” for variable name
DO use meaningful words for variable name
DO use implicit type “var” for local variable declarations with initialization
DO use predefined type name (int, string, float) instead of .NET types (Int32, String, Single) for variable declarations
DON’T use uncommon abbreviations for variable name
DON’T use Hungarian notation for variable name
DON’T use underscore for variable name
DON’T exceed 50 characters length for variable name
Enum
DO use PascalCase for enum name
DO use “noun” for enum name
DO use “singular word” for enum name
DON’T use suffix “Enum” for enum name
DON’T use underscore for enum name
DON’T exceed 50 characters length for enum name
Last updated