In c#, Abstract class is a class that can not be instantiated on its own
- In c#,
Abstract class
is a class that can not be instantiated on its own - It is typically used as a
base class
for other class. Abstract class
provides a way to achieveabstraction
, because there you can just declare the methods (abstract methods) and implement them later.- It can contain both
abstract methods
(methods without implementation details) andnon-abstract methods
(method with implementation details). - Similar goal can be achieved with
interface
, but in abstract class you can also define non-abstract method. These methods are needed when you need to share some common functionality.
public abstract class Shape
{
// it is the basic syntax of abstract class
}
Example:
[Read More]