← Back to Tools

C# Naming Conventions

Microsoft's official identifier naming rules & conventions

learn.microsoft.com ↗
PascalCase camelCase Prefix rules
Naming Rules by Identifier
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
Primary Constructor Parameters
Type Convention Example
class / struct camelCase — same as regular parameters DataService(IWorkerQueue workerQueue)
record PascalCase — they become public properties Person(string FirstName, string LastName)
Generic Type Parameter Guidelines
All-in-one Example
namespace Company.Product.Module { public interface IWorkerQueue // I + PascalCase { int Count { get; } } public record PhysicalAddress( // PascalCase params (record) string Street, string City, string ZipCode); public class DataService : IWorkerQueue // PascalCase { private IWorkerQueue _workerQueue; // _ + camelCase private static ILogger s_logger; // s_ + camelCase [ThreadStatic] private static TimeSpan t_elapsed; // t_ + camelCase public bool IsValid; // PascalCase (public field) public const int MaxRetryCount = 3; // PascalCase (constant) public event Action EventProcessing; // PascalCase (event) public void StartProcessing(int retryCount, bool isAsync) // camelCase params { var itemCount = 0; // camelCase (local var) static int CountItems() => 0; // PascalCase (local function) } } public interface ISessionChannel<TSession> // T + descriptive name { TSession Session { get; } } }
General Guidelines
Clarity over brevity. Prefer descriptive names like customerCount over cc. Single-letter names only for simple loop counters.
No double underscores. Names with __ are reserved for compiler-generated identifiers.
Avoid abbreviations unless widely recognized (e.g., Id, Html, Url are fine).
Enum naming: singular noun for non-flags (Color), plural noun for [Flags] enums (FilePermissions).