Data Structures and Algorithms
with Object-Oriented Design Patterns in C# |
A C# class defines a data structure that contains fields, methods, and nested types. Every type in C# has is a class that is directly or indirectly derived from the object class. The class of an object determines what it is and how it can be manipulated. A class encapsulates data, operations, and semantics. This encapsulation is like a contract between the implementer of the class and the user of that class.
The class construct is what makes C# an object-oriented language. A C# class definition groups a set of values with a set of operations. Classes facilitate modularity and information hiding. The user of a class manipulates object instances of that class only through the methods provided by that class.
It is often the case that different classes possess common features. Different classes may share common values; they may perform the same operations; they may support common interfaces. In C# such relationships are expressed using derivation and inheritance.