Microsoft's official identifier naming rules & conventions
learn.microsoft.com ↗| Identifier | Convention | Example |
|---|---|---|
| Class | PascalCase | DataService |
| Interface | I prefix + PascalCase | IWorkerQueue |
| Struct | PascalCase | ValueCoordinate |
| Delegate | PascalCase | DelegateType |
| Enum | PascalCase — singular (non-flags), plural (flags) | Color / FilePermissions |
| Record | PascalCase (params too) | PhysicalAddress(string Street, ...) |
| Namespace | PascalCase — reverse domain notation | Company.Product.Module |
| Public Method | PascalCase | StartEventProcessing() |
| Local Function | PascalCase | CountQueueItems() |
| Public Property | PascalCase | WorkerQueue |
| Public Field | PascalCase | IsValid |
| Public Event | PascalCase | EventProcessing |
| Constant | PascalCase | MaxRetryCount |
| Method Parameter | camelCase | someNumber, isValid |
| Local Variable | camelCase | workerCount |
| Private Field | _ prefix + camelCase | _workerQueue |
| Private Static Field | s_ prefix + camelCase | s_workerQueue |
| Thread Static Field | t_ prefix + camelCase | t_timeSpan |
| Attribute Type | PascalCase + Attribute suffix | ObsoleteAttribute |
| Generic Type Param | T prefix + PascalCase | TSession, TOutput |
| Type | Convention | Example |
|---|---|---|
| class / struct | camelCase — same as regular parameters | DataService(IWorkerQueue workerQueue) |
| record | PascalCase — they become public properties | Person(string FirstName, string LastName) |
T (e.g., TSession, TInput)T only when the meaning is obvious: List<T>, Predicate<T>TSession for an ISession constraintcustomerCount over cc. Single-letter names only for simple loop counters.
__ are reserved for compiler-generated identifiers.
Id, Html, Url are fine).
Color), plural noun for [Flags] enums (FilePermissions).