Types, Objects, and Instances

You’ve seen how types are containers for data/code. Although some types may just contain data, others may solely consist of code. That’s just a first order approximation; further refinement is desirable. Notice how I’ve carefully used two terms from the preceding section: person class versus person object. So, what’s the distinction between the two?

Types are just blueprints that describe the shape of an object in terms of data contained in it and code operating on it. By themselves, types are just a way to classify different sorts of things our program needs to deal with in a safe manner. A thorough discussion of type safety is deferred until Chapter 11. An example of a type is Person, with a capital P, as we declared ...

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.