C# โ Properties & Events
Properties & Events
Section titled โProperties & EventsโProperty syntax evolved for terseness and correctness.
Feature map
Section titled โFeature mapโFeature map (advanced)
Section titled โFeature map (advanced)โComparison of property variants
Section titled โComparison of property variantsโVariant | Introduced | Description |
---|---|---|
Basic properties | C# 1.0 | Manual getter/setter with explicit backing field. |
Auto-implemented | C# 3.0 | Compiler-generated backing field. |
Read-only (get-only) | C# 6.0 | Immutable after construction. |
Auto-property initializers | C# 6.0 | Default values for auto-props. |
Expression-bodied (get/set) | C# 6.0๏ฟฝ7.0 | Concise accessors with => . |
Init-only (init ) | C# 9.0 | Settable only during initialization. |
Required members | C# 11.0 | Enforce initialization in object creation. |
Partial properties | C# 13.0 (preview) | Split accessors across partial types. |
field in accessors | C# 13.0 (preview) | Use implicit backing field inside accessors. |