#361 – An Abstract Property Has No Implementation

You can declare a property as abstract, indicating that it has no implementation in the base class.  The base class indicates the property’s type and whether it has get and set accessors in any derived classes.

A base class that defines an abstract property must also be marked as abstract itself.  It wouldn’t make sense to create instances of the base class, since the implementation for the abstract property is missing.

A derived class must provide the implementation (in get/set accessors) for any properties that are abstract in the base class.

Defining an abstract property:

    public abstract class Dog
        public abstract string Temperament { get; }

Providing an implementation for the get accessor in a derived class:

    public class Terrier : Dog
        protected string temperament;
        public override string Temperament
                return string.Format("Terrier {0} is {1}", Name, temperament);

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: