Auto-implemented properties

C# 3.0 NETFx 3.5

Published Updated Author Jeffrey T. Fritz Reading time

Auto-implemented properties let you declare a property with just { get; set; }, letting the compiler generate the backing field for you. They cut property boilerplate while keeping your intent crystal clear.

Before C# 3.0, even a simple property required declaring a backing field, a getter, and a setter. Auto-implemented properties arrived in C# 3.0 and let the compiler handle the field for you. You just write { get; set; } and move on.

Why it matters

Cuts property boilerplate dramatically. In a class with five simple properties, auto-implemented properties let you focus on what matters—the names and types—rather than repetitive field declarations.

Used everywhere in modern C#. Data transfer objects, configuration classes, entity models, and any class whose properties just store and retrieve values benefit from auto-properties.

Works seamlessly with initialization syntax. Auto-properties pair beautifully with C# 3.0 object initializers and with modern features like init-only properties (C# 9), letting you build immutable models without ceremony.

Transition path to computed properties. If a property starts simple, you can later add logic to the getter or setter without breaking calling code. Auto-properties give you room to grow.

Cautions

Avoid when you need property-level logic. If your getter or setter needs to validate input, log, trigger events, or perform side effects, you’ll need a manual backing field and custom logic. Don’t force auto-properties to do more than they should.

Watch nullable contexts in modern code. With nullable reference types enabled, auto-properties default to non-nullable. Be explicit about whether a property can hold null—use string? or string to communicate intent to other developers.

They’re still mutable by default. An auto-property with { get; set; } can be assigned from anywhere. If you need immutability, use { get; private set; } or upgrade to C# 9’s init accessor to signal that a value is set only during initialization.

Not a substitute for real validation. Auto-properties don’t validate range, format, or business rules. Guard your invariants in a constructor or use a property with logic if the field needs protection.

Replacing backing fields with auto-properties

Auto-implemented properties eliminate boilerplate field declarations for simple getters and setters.

Valid since C# 3.0

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
    public string City { get; set; }
}

Migrating from manual properties

See how auto-properties transform verbose property implementations into clean, minimal syntax.

Valid since C# 3.0

// Before: Backing fields and explicit properties
public class PersonOld
{
    private string _name;
    public string Name
    {
        get { return _name; }
        set { _name = value; }
    }
}

// After: Auto-implemented properties
public class PersonNew
{
    public string Name { get; set; }
}

Learn more

Auto-implemented properties (Microsoft Learn)