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 will be explained extensively when we cover OO programming with C#.

Classes are formally known as ...

Get C# 4.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.