簡體   English   中英

C# 如何將默認實現添加到覆蓋另一個接口的接口

[英]C# how to add a default implementation to an interface which is overriding another interface

例如:

interface IDottable : IGetDottable
{
    bool try_dot_operator(string name);
    // ... more methods
    IDottable Dottable => this;
}
interface IGetDottable
{
    IDottable Dottable {get;}
}

它給了我:

"'IDottable.Dottable' hides inherited member 'IGetDottable.Dottable'. Use the new keyword if hiding was intended.".

嘗試這個:

interface IDottable : IGetDottable
{
     bool try_dot_operator(string name);
     // ... more methods
     IDottable IGetDottable.Dottable => this;
}
interface IGetDottable
{
    IDottable Dottable {get;}
}

接口中的默認實現不會公開該方法。

暫無
暫無

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

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