C# Feature β Auto-implemented properties
Overview
Section titled βOverviewβAuto-properties remove the need for explicit backing fields when no custom logic is required.
Introduced In
Section titled βIntroduced InβC# 3 (2007)
private string _name;public string Name { get => _name; set => _name = value; }public string Name { get; set; }Annotated Example
Section titled βAnnotated Exampleβpublic class Person { public string Name { get; init; } }Gotchas & Best Practices
Section titled βGotchas & Best Practicesβ- Use
initfor immutability where possible (C# 9).
Related Features
Section titled βRelated FeaturesβVersion Notes
Section titled βVersion Notesβinitadded in C# 9; required members in C# 11.