我有用C#编写的接口,它已经由类实现了.是否有可能在界面中添加一个属性作为可选属性而不修改现有的实现类?
例如
public interface IShape
{
int area { get; }
}
public class FindWindow : IShape
{
public int area
{
get
{
return 10;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这个FindWindow已经写好了.是否可以添加一个可选属性而不在现有类中实现.
即
public interface IShape
{
int area { get; }
//optional
//string WindowName{get;}
}
public class FindWindow : IShape
{
public int area
{
get
{
return 10;
}
}
//WindowName i am not implementing here
}
public class FindWindowName : IShape
{
public int area
{
get { return …
Run Code Online (Sandbox Code Playgroud)