// Abstract property in an abstract base class.
public abstract string PetName { get; set; }
}
When defining automatic properties, you simply specify the access modifier, underlying data
type, property name, and empty get/set scopes. At compile time, your type will be provided with an
autogenerated private backing field and a fitting implementation of the get/set logic.
■
Note
The name of the autogenerated private backing field is not visible within your C# code base. The only way
to see it is to make use of a tool such as
ildasm.exe
.
Unlike traditional C# properties, however, it is not possible to build read-only or write-only
automatic properties. While you might think you can just omit the get; or set; within your property
declaration as follows:
Do'stlaringiz bilan baham: |