Code Standards
Coding conventions, naming patterns, and style guidelines
ReferenceBeginner• 12 min read
C# Naming Conventions
Consistent naming patterns across the .NET codebase
✓ Correct
public class UserService
public interface IUserRepository
public string DisplayName { get; set; }
private readonly ILogger _logger;
public const int MAX_RETRY_COUNT = 3;
✗ Incorrect
public class userService
public interface UserRepository
public string display_name { get; set; }
private readonly ILogger logger;
public const int maxRetryCount = 3;
Classes & Interfaces
- • PascalCase for classes
- • Interface prefix with 'I'
- • Descriptive, not abbreviated
Methods & Properties
- • PascalCase for public members
- • camelCase for parameters
- • Verb for methods, noun for properties
Fields & Constants
- • _fieldName for private fields
- • UPPER_CASE for constants
- • camelCase for local variables
File Organization
Standard file structure and organization patterns
ModernAPI.Domain/
├── Entities/
│ └── User.cs # One class per file
├── ValueObjects/
│ └── Email.cs # Value object classes
├── Events/
│ └── UserCreatedEvent.cs # Domain events
├── Exceptions/
│ └── UserNotFoundException.cs
└── Interfaces/
└── IUserRepository.cs # Repository contracts
File Naming Rules
- • Match the primary class name exactly
- • Use PascalCase for file names
- • One primary class per file
- • Organize by feature, not by type