C# provides modifiers to modify the declarations of types and type members. We have discussed Access Modifiers in our previous Articles. In this Article, we will discuss one of the modifier which is abstract
Modifier.
abstract
Modifier
We use this modifier to indicate the type has incomplete implementation. This can be used with below types:
- Classes
- Properties
- Methods
- Indexers and
- Events
abstract
keyword is used to define abstract types. For example, an abstract class. An abstract class can not be instantiated due to the incompleteness. Classes can be instantiated only once they are completed.
Below is the example we define an abstract class.
abstract class BaseClass
{
}
If you attempt to create an instance of an abstract class, you will see the below Error message.
Error 1 Cannot create an instance of the abstract class or interface 'abstract.BaseClass'
We will discuss more topics in upcoming Articles.
(Raju)