After our coverage of the code aspects of types in Chapter 10, we aimed our discussion at their data aspect in this chapter. Both aspects are quintessential in the definition of types. Nonetheless, some members of types don’t fall in just one category (for example, properties and indexers).

First, you explored the extreme end of a type’s state spectrum by covering fields, which act as containers for state associated with a type or an instance of a type. You learned how to declare and initialize fields, also covering the notion of read-only fields that are immutable outside what’s known as the constructor. At first sight, constants are similar to read-only fields, so you learned about some important differences.

After talking about fields, ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.