C# Windows Forms Programming
Learn C# (C sharp) in FREE step-by-step lessons.
Object oriented programming in C#
You have been using classes and objects throughout this course.
In this lesson, you will create your own class.
Important Terms
- Accessors: Accessors retrieve values from the class, usually named get___, also called getter functions
- Attributes: Variables that are defined in a class are called attibutes or properties.
- Class: code that specifies the attributes *variables) and member functions (methods)
- Constructor: Method with same name as class, used to give initial values to the attributes.
- Data hiding: making attributes (variables) private and controlling access to them with methods (functions)
- Destructor: Member function with same name as the class with a ~ in front. The destructor is called when the object is destroyed.
- Encapsulation: combining data and code into a single object
- Instance: An object created from the class. (Using a constructor)
- Members: Objects can have their own data, including variables and constants, and their own methods. The variables, constants, and methods associated with an object are collectively refered to as its members or features.
- Mutators: Mutators change the values in the class, usually named set___, also called setter functions.
- Object: combines data(attributes, properties, variables) and member functions(methods).
- Overloaded constructors: Constructors can be written with different parameters. Usually there is one constructor with no arguments (the default constructor) and ones with different attributes given values.
- Overriding:Writing a method such as ToString() that already exists for a class by default.
- Private: (access specifier) Private attributes and methods can only be used inside the class definition.
- Public: (access specifier) Public attributes and methods are ones that can be accessed outside the class definition.
Please study the material at each of the links below.
Microsoft Reference: Classes vs. Structs: A class can be described as the blueprint or template for creating an instance of the class. An instance of the class is called an object. An object combines both data (properties) and events (procedures).
- Fraction Class with variables and constructors
/csharp/videos/csharp-fraction.mp4
- Fraction Class with Accessors, Mutators, and <
/csharp/videos/csharp-fraction2.mp4
- Working with the DateTime class.
- A Person Class.
- An Employee Class derived from the Person Class (Inheritance).
Glossary for objects lessonFull Glossary