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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.