I have defined an interface, an abstract class that implements that interface and a class that derives from the abstract class. I need the interface because I am using a dynamic loader to implement the plugins and I created an abstract class to implement a few things that all plugins will have.
Now I want to implement a class-wide string as a name. What I created is this:
public interface IDevicePlugin {
string name { get; }
}
abstract public class DevicePlugin : IDevicePlugin {
abstract public string name { get; }
}
public class somePlugin : DevicePlugin, IDevicePlugin {
public override string name {
get {
return "my name";
}
}
}
But this gives me the error “cannot override because ‘name’ is not a property’. If I remove the override, it says it is hiding the inherited member ‘name’.
How do I correctly implement this?
It doesn’t error for me, but… I suspect that this is because you are re-implementing the interface. Drop the
, IDevicePlugininsomePlugin:It inherits the interface from the parent class.