이 클래스 내에 기본 속성과 중첩 클래스를 숨기는 속성이있는 클래스가 있다고 가정 해 보겠습니다. 베이스에 액세스 할 수 있습니까 숨김 * 가상 * 중첩 클래스의 속성입니까?중첩 클래스의 외부 클래스 숨겨진 기본 속성에 액세스
class BaseClass
{
protected virtual String SomeProperty {get; set;}
}
class Inherited : BaseClass
{
protected new String SomeProperty {get; set;}
class Nested
{
Inherited parent;
public Nested(Inherited parent)
{
this.parent = parent;
}
public void SomeMethod()
{
//How do I access the SomeProperty which belongs to the BaseClass?
}
}
}
내가 생각할 수있는 유일한 해결책은 더 나은 솔루션이 있습니까 base.SomeProperty
을 반환 상속 클래스에 private 메소드를 추가하는 것입니다 : 여기
어디에서 액세스하려고합니까? 왜 처음에 속성을 숨겼습니까? –
중첩 클래스의 메서드에서 액세스하려고합니다. 새 속성이 기본 속성보다 많은 기능을 제공하고 두 가지 속성을 갖고 싶지 않기 때문에 기본 속성을 숨 겼습니다. – Giorgi