Abstract Class
Abstract class is used to obtain the common characteristics of subclasses. It’s contain complete and abstract (incomplete) both types of member and it cannot be instantiated. This article describes theintroduction to abstract class in C#. Summary of the article:
- What is Abstract Class?
- Example of Abstract Class
- When to use Abstract Classe?
- Features of Abstract Class
What is Abstract Class?
In .NET technology Abstract class is one of the essential properties. Abstract classes are closely related to the interfaces. Generally we used an abstract class when we would like to make a class that only represent base class, and don’t want anyone to create objects of these class types. We can get such functionality in C# using the modifier ‘abstract’. In short an abstract class means that, no object of this class can be instantiated, but can make derivations of this.
In .NET technology Abstract class is one of the essential properties. Abstract classes are closely related to the interfaces. Generally we used an abstract class when we would like to make a class that only represent base class, and don’t want anyone to create objects of these class types. We can get such functionality in C# using the modifier ‘abstract’. In short an abstract class means that, no object of this class can be instantiated, but can make derivations of this.
An abstract class can contain either abstract members or non abstract members. Abstract members do not have any implementation in the abstract class, but the same has to be provided in its derived class.
Example of Abstract Class
An example of an abstract class declaration is:
An example of an abstract class declaration is:
abstract class myabsClass
{
}
{
}
When to use Abstract Classe?
We can use abstract classes when we don’t want to implement all the functionality in the class. We want to implement some functionality in class and the remaining functionality in child classes.
We can use abstract classes when we don’t want to implement all the functionality in the class. We want to implement some functionality in class and the remaining functionality in child classes.
Features of Abstract Class
Abstract classes have the following features:
Abstract classes have the following features:
- An abstract class cannot be instantiated.
- An abstract class may contain abstract (incomplete) methods and non-abstract (complete) methods.
- We can’t modify an abstract class with the sealed modifier.Because they have opposite meanings.The sealed modifier prevents a class from being inherited and the abstract modifier makes a class to be inherited.
- A non abstract class derived from an abstract class and must implements all inherited abstract methods.
That’s all about abstract class.
No comments