Back to Writing
NOTEScsharpcoding-standardsbest-practices

C# Coding Standards

September 28, 2020Updated Feb 17, 2026

C# Coding Standards:

  1. Naming Conventions:

    • Classes: PascalCase (MyClass)
    • Methods: PascalCase (MyMethod)
    • Variables: camelCase (myVariable)
    • Constants: UPPER_CASE (MY_CONSTANT)
  2. Code Formatting:

    • Use 4 spaces for indentation.
    • Place opening braces on the same line.
  3. Code Organization:

    • One class per file
    • Organize using statements at the top.
    • Use regions for code organization.
  4. Comments:

    • Use meaningful comments.
    • Avoid obvious comments.
  5. Performance:

    • Avoid boxing and unboxing.
    • Use const for compile-time constants.
    • Avoid string concatenation in loops.
  6. Best Practices:

    • Use try-catch for error handling.
    • Implement proper null checks.
    • Use LINQ for collections.