#228 – Object-Oriented Programming in C# Using Classes
January 31, 2011 1 Comment
Classes are the construct in C# that enable the object-oriented paradigm and make C# an object-oriented language.
Classes are the user-defined types that define a set of related data and the methods that act upon that data. Each instance of the class (an object) has a set of values for the class’ data, know as the object’s state.
Object-orientation is a powerful paradigm to use when writing software because using classes and objects helps you think about things, rather than algorithms.
For example, we might have a Dog class with data fields like: Name, Age, Breed, LikesBalls, and PersonalityType. We might have methods in the Dog class like Bark, Sit, and Fetch. Each instance of a Dog would have different values for these fields and we can call any of the Dog methods on an instance of a dog and it would respond based on the value of these fields.