C Sharp Coding Standards

Naming Conventions

  • “c” = camelCase
  • “P” = PascalCase
  • “_” = Prefix with _Underscore
  • “x” = Not Applicable.
IdentifierPublicProtectedInternalPrivateNotes
Project File P x x x Match Assembly & Namespace.
Source File P x x x Match contained class.
Other Files P x x x Apply where possible.
Namespace P x x x Partial Project/Assembly match.
Class or Struct P P P P Add suffix of subclass.
Interface P P P P Prefix with a capital I.
Generic Class 
[C#v2+]
P P P P Use T or K as Type identifier.
Method P P P P Use a Verb or Verb-Object pair.
Property P P P P Do not prefix with Get or Set.
Field P P P _c Only use Private fields. 
No Hungarian Notation!
Constant P P P _c  
Static Field P P P _c Only use Private fields.
Enum P P P P Options are also PascalCase.
Delegate P P P P  
Event P P P P  
Inline Variable x x x c Avoid single-character and enumerated names.
Parameter x x x c  
posted @ 2013-04-27 13:27  重庆Debug  阅读(233)  评论(0编辑  收藏  举报