Classes, Structures, and Enumerations

Because the CLI is inspired by the principles of OO programming, it shouldn’t surprise you that classes are one kind of type the CLI supports. In essence, a class is a container for data and operations that can be performed on that data. By keeping the data representation of a class private, one reaches the virtue of encapsulation, where implementation details can change as long as the public contract stays the same.

Also in true OO style, the CLI supports the creation of class hierarchies, where one type derives from another. For example, an Apple type could derive from a Fruit base class. The details of this are explained extensively when we cover OO programming with C#.

Classes are formally known as

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.