© Vaskaran Sarcar 2018
Vaskaran SarcarInteractive C#https://doi.org/10.1007/978-1-4842-3339-9_6

6. Encapsulation with Properties and Indexers

Vaskaran Sarcar
(1)
560066 Bangalore, Karnataka, India
 

Overview of Properties

Teacher starts the discussion: We already know that encapsulation is one of the key characteristics in object-oriented programming. In C#, properties are very important because they help encapsulate an object state. A property is a member that provides a flexible mechanism to read, write, or compute the value of a private field. Initially, properties may appear similar to fields, but actually they have either get or set or both blocks attached with them. These special blocks/methods are called accessors . In simple terms, get blocks ...

Get Interactive C#: Fundamentals, Core Concepts and Patterns 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.