1
인터페이스 (ItestClass)를 통해 기본 클래스 (testClass) 속성에 액세스 할 수없는 이유는 무엇입니까? 실제 컨트롤 (winforms/wpf) 속성이 세 번째 클래스 (newClass)에 표시되지 않도록 인터페이스를 만들었습니다. 그게 가능하지 않다면 더 좋은 방법이 있을까요?클래스 인터페이스를 통해 클래스의 속성에 액세스
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;
}
}
@mason은 'newClass'가 아닙니다. –
문제는 단순히 모든 test 속성을 보여주기 때문에 testClass를 직접 상속받지 않으려 고합니다. 대신 피할 수있는 인터페이스를 상속받습니다. – Johnny
기본적으로 세 번째 클래스 (newClass)에서 다시 정의해야합니다. – Johnny