Back to Writing
NOTEScsharpcoding-standardsbest-practices
C# Coding Standards
September 28, 2020•Updated Feb 17, 2026
C# Coding Standards:
-
Naming Conventions:
- Classes: PascalCase (MyClass)
- Methods: PascalCase (MyMethod)
- Variables: camelCase (myVariable)
- Constants: UPPER_CASE (MY_CONSTANT)
-
Code Formatting:
- Use 4 spaces for indentation.
- Place opening braces on the same line.
-
Code Organization:
- One class per file
- Organize using statements at the top.
- Use regions for code organization.
-
Comments:
- Use meaningful comments.
- Avoid obvious comments.
-
Performance:
- Avoid boxing and unboxing.
- Use const for compile-time constants.
- Avoid string concatenation in loops.
-
Best Practices:
- Use try-catch for error handling.
- Implement proper null checks.
- Use LINQ for collections.