Auto-Implemented Prop

In C# 3.0 and later, auto-implemented properties make property-declaration more concise when no additional logic is required in the property accessors. They also enable client code to create objects. When you declare a property as shown in the following example, the compiler creates a private, anonymous backing field can only be accessed through the property’s get and set accessors.

// Auto-Impl Properties for trivial get and set

public double TotalPurchases { get; set; }

public string Name { get; set; }

public int CustomerID { get; set; }

Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: