Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have a abstract class

public abstract class Service
    {
        public abstract void DoWork();

    }


and sub classes are

public class Updater : Service
 {

 }


and

public class Sweeper : Service
{
    public string Path
    {
        get;
        set;
    }

    public int DaysToKeep
    {
        get;
        set;
    }
}


but when I want to build the project it give me an error :
'MyService.Sweeper' does not implement inherited abstract member 'MultiPurposeService.Service.DoWork() '


What I have tried:

solve this error :
does not implement inherited abstract member
Posted
Updated 13-Jun-17 23:09pm

1 solution

Reading the error's documentation can be good idea sometimes...
A class is required to implement all the abstract members in the base class, unless the class is also abstract.

And if you ask yourself why... Abstract methods has no implementation by definition, however, now you created a new class - Sweeper - which has (inherited) a method - DoWork.
What should happen when you call Sweeper.DoWork? Some mess, as there is no implementation at all to that method. Therefore, the first non-abstract class in the chain must implement the method...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900