trinalbadger587
trinalbadger587

Reputation: 2109

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

For example:

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

It gives me:

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

Upvotes: -2

Views: 63

Answers (1)

trinalbadger587
trinalbadger587

Reputation: 2109

Try this:

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

Default implementations in interfaces do not make the method public.

Upvotes: 1

Related Questions