Reputation: 43833
If I have an interface
interface ISite {
int g { get; set; }
}
and a base class
class Site {
public int g = 1;
}
and a derived class that implements the interface and extends the class
class DSite : Site, ISite {
// comaplains g is not defined
}
It complains that I did not implement the g
property, but how do I make it take it from the parent class Site
?
Upvotes: 0
Views: 307
Reputation: 8295
Either make g in Site
a property:
class Site
{
public int g {get;set;} = 1;
}
or explicitly implement the interface in DSite
:
class DSite : Site, ISite
{
int ISite.g
{
get { return g; }
set { g = value; }
}
}
Upvotes: 1