Data Access, Properties, and Methods
- slide 3 : 29
Overview of data access in C#
In C# the data of a class can be accessed in several different ways
Data access
Directly via public instance variables
Never do that!
Indirectly via properties
Clients cannot tell the difference between access via properties and direct access of instance variables
Indirectly via methods
Should be reserved for "calculations on objects"
Indirectly via indexers
Provides access by means of the notation known from traditional array indexing
Indirectly via overloaded operators
Provides access by means of the language-defined operator symbols