#351 – An Abstract Method Has No Implementation

An abstract method is a special kind of virtual method, defined in a base class, which has no implementation of its own.  A derived class must define every abstract method and provide an implementation, using the override keyword.

    public abstract class Dog
    {
        // Abstract method has no implementation
        public abstract void Bark();
    }

    public class Terrier : Dog
    {
        public override void Bark()
        {
            Console.WriteLine("Terrier {0} is barking", Name);
        }
    }

The class in which the abstract method is defined must be defined as an abstract class, using the abstract keyword.

A derived class may not hide the abstract method in the base class, using the new keyword.  It must implement the inherited abstract method and the new method must be a virtual method, defined using the override keyword.

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

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 )

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

%d bloggers like this: