Naming Convention in c#

Microsoft has an excellent set of guidelines on class library design, including a section on naming. In short (examples in parentheses):

  • Classes/Structs: PascalCase (WebRequest)
  • Interfaces: PascalCase with I prefix (IDisposable)
  • Methods: PascalCase (ToUpper)
  • Properties: PascalCase (Length)
  • Events: PascalCase (Click)
  • Namespaces: PascalCase (System.Collections; unusual to have two words in one part though)
  • Non-constant variables including parameters: camelCased (keySelector)
  • Constants: PascalCase (Int32.MaxValue)
  • Enums: PascalCase, singular for non-flags and plural for flags (HttpStatusCode, BindingFlags)
  • Attributes: PascalCase with "Attribute" suffix (ThreadStaticAttribute)

Private names are up to you, but I tend to follow the same conventions as for everything else. Hungarian notation (in the style of Win32) is discouraged, although many places use "m_" or "_" as a prefix for instance variables.


Resharper's guidelines suggest


  • Types and namespaces UpperCamelCase
  • Interfaces IUpperCamelCase
  • Type parameters TUpperCamelCase
  • Methods properties and events UpperCamelCase
  • Local variables lowerCamelCase
  • Local constants lowerCamelCase
  • Parameters lowerCamelCase
  • Fields (not private) UpperCamelCase
  • Instance fields (private) _lowerCamelCase
  • Static field (private) _lowerCamelCase
  • Constant fields (not private) UpperCamelCase
  • Constant fields (private) UpperCamelCase
  • Static readonly fields (not private) UpperCamelCase
  • Static readonly fields (private) UpperCamelCase
  • Enum members UpperCamelCase
  • All other entities UpperCamelCase

The .NET standard from Microsoft is to use Pascal Case for namespaces, public and protected members (basically anything visible to other classes). For private members and local variables, there's a much wider berth to just do whatever you and your team are most comfortable with.