#229 – The Core Principles of Object-Oriented Programming
February 1, 2011 4 Comments
As an object-oriented language, C# supports the three core principles of object-oriented programming:
- Encapsulation – Hide implementation details in a class from users of the class, exposing only a public interface
- Inheritance – Derive a subclass from a parent class, inheriting data and behavior from the parent, in an “is-a” relationship. Inheritance defines a hierarchy of classes. All classes ultimately inherit from System.Object.
- Polymorphism – Any subtype may be used where a parent type (or type higher up in the class hierarchy) is expected. Conversely, a variable of a particular class will be treated as the appropriate subclass.