12
Properties and Indexers [email protected] Programming in C#

9 properties & indexers

Embed Size (px)

Citation preview

Page 1: 9   properties & indexers

Properties and Indexers

[email protected]

Programming in C#

Page 2: 9   properties & indexers

Properties

Page 3: 9   properties & indexers

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.

Page 4: 9   properties & indexers

Get & Set accessors

https://gist.github.com/2391947

Page 5: 9   properties & indexers

Types of Properties

Page 6: 9   properties & indexers

Difference between Properties and Fields

Page 7: 9   properties & indexers

Difference between Properties and Methods

Page 9: 9   properties & indexers

Indexers

Page 10: 9   properties & 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

Page 11: 9   properties & indexers

Implementation

https://gist.github.com/2398898

Page 12: 9   properties & indexers

Difference between Properties and Indexers