You can re-declare it (or rather, tell the compiler that you intend to hide it):
public interface IChangeable : IBasic
{
new int Data { set; }
}
class Foo : IChangeable
{
private int value;
int IBasic.Data { get { return value; } }
int IChangeable.Data { set {this.value = value;} }
}
But this is confusing, and you'll need to use explicit implementations etc, and probably a bit of casting at the caller if you want to use the hidden version. If you went this route, I would recommend exposing both the get
and set
on IChangeable
:
public interface IChangeable : IBasic
{
new int Data { get; set; }
}
class Foo : IChangeable
{
private int value;
int IBasic.Data { get { return value; } }
int IChangeable.Data { set { this.value = value; } get {return value; } }
}
Re the comments; to expose on the implementing type:
public interface IChangeable : IBasic
{
new int Data { set; }
}
public interface IBasic
{
int Data { get; }
}
class Foo : IChangeable
{
private int data;
public int Data {
get { return data; }
set { data = value; }
}
}
This would also work if you make it (which I prefer):
public interface IChangeable : IBasic
{
new int Data { get; set; }
}