CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

C# – Modifiers – abstract Modifier

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)

C# – Modifiers – abstract Modifier

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top