그게 당신이 찾고있는 것입니까?
public class BaseClass : ISomeInterface, ISomeOther
{
public int Prop1 { get; set; }
public int Prop2 { get; set; }
public int Prop3 { get; set; }
}
public class Derived : BaseClass
{
// inherits all 3 props
}
public interface ISomeInterface
{
int Prop1 { get; }
int Prop2 { get; }
}
public interface ISomeOther
{
int Prop3 { get; }
}
public static class Program
{
public static void Main()
{
BaseClass instance1 = new BaseClass(); // IntelliSense shows all 3 props
Derived instance2 = new Derived(); // IntelliSense shows all 3 props
ISomeInterface instance3 = new BaseClass(); // IntelliSense shows 2 props from interface
ISomeOther instance4 = new BaseClass(); // IntelliSense shows only Prop3
}
}
특정 인터페이스의 기능을 분해하여 사용중인 인터페이스에 따라 특정 기능 하위 집합을 제공 할 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다