Skip to main content

Solution Naming Guidelines

C# and VB.net naming conventions play a crucial role in ensuring code readability, maintainability, and consistency across projects. These conventions assist developers in quickly understanding the purpose and usage of code elements like classes, methods, variables, and more. Adhering to established naming standards/conventions promotes teamwork and facilitates smoother code reviews and maintenance.

General Guidelines

  1. Choose easily readable, preferably grammatically correct names. For example, HorizontalAlignment is more readable than AlignmentHorizontal.
  2. Favor readability and clarity over brevity and abbreviated names.
  3. Avoid using names that conflict with reserved keywords of used programming languages.
  4. Use PascalCase for class names, file names, namespaces, all method names, and public member names. Use camelCase for private fields, parameters and local variables. See below for reference:
NameCase TypeExample
NamespacePascalnamespace CompanyName.ProjectName{…}
Class/TypePascalpublic class ClassName {…}
InterfacePascalpublic interface IBusinessService {…}
MethodPascalprivate void MethodName()
Property/FieldPascalpublic int PropertyName {get; set;}
EnumPascalpublic enum ErrorLevel
Enum MemberPascalCriticalLevel
ConstantSnake, All Capspublic const string TEST_BASE_URL
ParametersCamelprivate string GetParameter(string parameterName)
Local VariablesCamelvar localVariable = “Test”
StructPascalpublic struct StructName
Resource KeyPascalSaveButtonTooltipText
  1. Do not use abbreviations. For example, use ButtonOnClick rather than BtnOnClick.
  2. Name a Variable in a most descriptive way possible. Example: if a SessionInfo variable that is passed to other calls, is allowed to be null, name it sessionInfoOrNull instead of the usual sessionInfo.
  3. Name Classes as Nouns or Noun phrases.
  4. Do not prefix class names (ex. “CMyDatabaseObject”).
  5. End the name of a derived class with the name of the base class.
  6. Name Interfaces as adjective phrases or occasionally as nouns or noun phrases.
  7. Prefix Interfaces with the letter "I", to indicate that the type is an interface.
  8. Name Methods as Verbs or Verb phrases.
  9. Name Properties and Fields as a Nouns, Noun phrases, or Adjectives.
  10. Do not prefix property names with Get or Set; these typically indicate that the property should be a method.
  11. Name collection properties with a plural phrase; not something like ItemList or ItemCollection.
  12. Name Boolean properties with a positive phrase (CanSeek instead of CantSeek).
  13. Use var to declare a variable if the type can be easily inferred from the name, otherwise use the type.
  14. Use syntactically interesting names, rather than a language-specific keywords for type names. For example, GetLength is a better name than GetInt.
  15. Use a singular type name for an enumeration unless its values are bit fields.
  16. Use a plural type name for an enumeration with bit fields as values.
  17. Do not use “Enum” or “Flag(s)” as a suffix for an enum type name.
  18. Do not use a prefix for a name on an enumeration value.
  19. Name Events as a Verb or Verb Phrase (ex. Clicked, Show, ShowDialog).
  20. Use -ing and -ed to express pre-events and post-events. For example:
  • Deleting: Occurs just before the object is getting deleted.
  • Delete: Occurs when the object needs to be deleted by the event handler.
  • Deleted: Occurs when the object is already deleted.
  1. Prefix an event handler with "On". For example, a method that handles its own Closing event should be named OnClosing.
  2. Use descriptive names for Parameters.
  3. Use parameter names based on its meaning rather than its type.
  4. Postfix asynchronous methods with Async or TaskAsync

Was this page helpful?