Chapter 3

Working with the Type System

What You Will Learn in This Chapter

  • Using C# value types
  • Understanding data structures
  • Using enumerations
  • Understanding C# reference types
  • Working with reference types properties
  • Understanding encapsulation
  • Using generics


You can find the code downloads for this chapter at on the Download Code tab. The code is in the chapter03 download and individually named according to the names throughout the chapter.

This chapter introduces you to the type system in C#, which provides the infrastructure necessary to model objects and handle the different types of data and information within a program. As a result, the exam tests your abilities to create and consume types in the C# language.

To help you gain this understanding, you explore types in a sequenced and logical manner. Value types are the simplest types in C#, and the chapter starts there. Not only are they the basic core types you need to store values and data in your code, but they are also used to maintain properties, which are components of C# classes. Class properties define characteristics of the classes you create.

Next, you look at reference types, which Microsoft defines as types that “store references to the actual data.” Another term for reference types is classes.

The key to working with reference types such as a C# class is the concept of encapsulation. Encapsulation enables a developer to create ...

Get MCSD Certification Toolkit (Exam 70-483): Programming in C# now with O’Reilly online learning.

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