【发布时间】:2014-06-11 10:24:30
【问题描述】:
为什么我不能通过它的接口(ItestClass)访问基类(testClass)的属性? 我创建了接口以避免在第三类 (newClass) 中显示实际的 Control (winforms/wpf) 属性。如果这不可能,有更好的方法吗?
public class testClass : Control, ItestClass
{
public int Property1 { set; get; }
public int Property2 { set; get; }
public testClass() { }
}
public interface ItestClass
{
int Property1 { get; set; }
int Property2 { get; set; }
}
public class newClass : ItestClass
{
public newClass()
{
// Why are the following statements are not possible?
Property1 = 1;
// OR
this.Property1 = 1;
}
}
【问题讨论】: