C# Modifier: abstract

Modifier: abstract

Used to declare an incomplete implementation of a class, method, property, indexer or event.

By declaring a class abstract, it can be used as a template when creating other classes. In the example below, the abstract class A forces any classes that are derived from it to include a ‘Test’ method. Failure to include the Test method will result in an error when compiling.

Example:
    abstract class A
    {
        public abstract void Test();
    }
    class B : A
    {
        public override void Test()
        {
        }
    }

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s