简体   繁体   中英

How do I inherit from class that calls base constructor?

So I've inherited this test platform for a Xamarin app for Android written in C# for Specflow. I know nothing about Xamarin, very little about Specflow, and its been 10 years since I did any coding in C#, so bear with me.. Trying to create a class that inherits from Button, I get this error:

There is no argument given that corresponds to the required formal parameter 'controlIdQuery' of 'Button.Button(Func <AppQuery, AppQuery>)'

My derived class looks like this:

public class Buttons : Button
{
}

Button class looks like this:

public class Button : ControlBase
{ 
    public Button(Func<AppQuery, AppQuery> controlIdQuery) : base(controlIdQuery) { }
}

And the parrent class, ControlBase of Button looks like this:

public abstract class ControlBase : AppBase
{
    public Func<AppQuery, AppQuery> controlIdQuery;

    public AppResult[] _appresult;
    public static IApp _appelement;
    public string _methodName;
    public object _argument;
    public bool waiting;
    public static Platform _appPlatform;

    public ControlBase(Func<AppQuery, AppQuery> idQuery)
    {
    }
}

I would expect to be able to create a class based on Button, as I can with the other control classes. What can I do to enable inheritance here?

your class's constructor needs to call the base class constructor

public class Buttons : Button
{
   public Buttons(Func<AppQuery, AppQuery> controlIdQuery) : base(controlIdQuery) {}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM