9 properties & indexers

Preview:

Citation preview

Properties and Indexers

tnngo2@gmail.com

Programming in C#

Properties

Properties ( smart fields)

ensure accuracy and validity of values of fields.

Use of properties Modifies private values

Validates private values

Performs required actions

Implements abstraction and encapsulation.

Get & Set accessors

https://gist.github.com/2391947

Types of Properties

Difference between Properties and Fields

Difference between Properties and Methods

Indexers

Indexers

are data members that allow access data within objects in a way

similar to accessing arrays.

fast access to the data within an object as they help in indexing the data

called smart arrays

Implementation

https://gist.github.com/2398898

Difference between Properties and Indexers

Recommended