Chapter 15
Implementing properties to access fields
After completing this chapter, you will be able to:
Encapsulate logical fields by using properties.
Control read and write access to properties by declaring
get
accessors andset
accessors.Explain the restrictions of properties.
Create interfaces that declare properties.
Implement interfaces containing properties by using structures and classes.
Generate properties automatically based on field definitions.
Use properties to initialize objects.
Implement records based on property values.
This chapter looks at how to define and use properties to encapsulate fields and data in a class. Previous chapters emphasized that you should make the fields in a class private and provide methods to store ...
Get Microsoft Visual C# Step by Step, 10th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.