#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.

Advertisements