O'Reilly logo

Microsoft® Visual C#® 2012 Step by Step by John Sharp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15. Implementing Properties to Access Fields

After completing this chapter, you will be able to

  • Encapsulate logical fields by using properties.

  • Control read access to properties by declaring get accessors.

  • Control write access to properties by declaring set accessors.

  • 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.

This chapter looks at how to define and use properties to encapsulate fields and data in a class. Previous chapters have emphasized that you should make the fields in a class private and provide methods to store values in them and to retrieve their values. This approach ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required