Auto-Implemented Properties · TL;DR

1 min read
Mid-level8 min read
Rapid overview

TL;DR

An auto-implemented property (public string Name { get; set; }) is a property whose storage the compiler writes for you: a hidden private backing field (<Name>k__BackingField) plus get_Name / set_Name accessor methods. At runtime the object holds only the field; the JIT inlines the trivial accessors, so reading an auto-property costs the same as reading a field. You still get everything a property gives over a public field: a stable binary contract, interface support, serialization, data binding, and the ability to add logic later. The variations interviewers ask about: get-only ({ get; }, assignable only in the constructor), private set, init (C# 9, set during object initialization and with), required (C# 11, must be set by the caller), property initializers (= new();), and the field keyword (C# 14) for adding logic without declaring a backing field. The classic trap: { get; } = new List<T>() creates one list, while => new List<T>() creates a new list on every read.