A class is an organized store-house in object-oriented programming that gives coherent functional abilities to a group of related code. It is the definition of an object, made up of software code. Using classes, we may wrap data and behavior together (Encapsulation). We may define classes in terms of classes (Inheritance). We can also override the behavior of a class using an alternate behavior (Polymorphism).
A Base Class is a class that is inherited by another class. In .NET, a class may inherit from only one class.
Encapsulation – is the ability of an object to hide its data and methods from the rest of the world. It is one of the fundamental principles of OOPs.
Say we create a class, named Calculations. This class may contain a few members in the form of properties, events, fields or methods. Once the class is created, we may instantiate the class by creating an object out of it. The object acts as an instance of this class, the members of the class are not exposed to the outer world directly, rather, they are encapsulated by the class.
Public class Calculations
private void fnMultiply(int x, int y)
return x * y;
Result = obj.fnMultiply(5,10);
Use the keyword NotInheritable in VB.NET and sealed in C#.
Use the keyword NotOverridable in VB.NET and sealed in C#.
Encapsulation is the OOPs concept of binding the attributes and behaviors in a class, hiding the implementation of the class and exposing the functionality.
A private constructor may be used to prevent the creation of an instance for a class.
When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.