簡體   English   中英

如何從調用基本構造函數的類繼承?

[英]How do I inherit from class that calls base constructor?

因此,我已經繼承了用C#為Specflow編寫的Android Xamarin應用程序的測試平台。 我對Xamarin一無所知,對Specflow卻一無所知,距離我用C#編寫代碼已有10年了,所以忍受一下。.嘗試創建一個繼承自Button的類時,出現此錯誤:

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

我的派生類如下所示:

public class Buttons : Button
{
}

Button類如下所示:

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

而父類Button的ControlBase看起來像這樣:

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)
    {
    }
}

我希望能夠像其他控件類一樣基於Button創建一個類。 我該怎么做才能在此處啟用繼承?

您的類的構造函數需要調用基類的構造函數

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM