이것은 수용 가능한 디자인입니까 ??추상 클래스 디자인
추상 클래스
public abstract class SomethingBase
{
public abstract int Method1(int number1);
public abstract int Method2(int number2);
}
public class Class1 : SomethingBase
{
public override int Method1(int number1)
{
//implementation
}
//i dont want this method in this class
public override int Method2(int number2)
{
throw new NotImplementedException();
}
}
public class Class2 : SomethingBase
{
//i dont want this method in this class
public override int Method1(int number1)
{
throw new NotImplementedException();
}
public override int Method2(int number2)
{
//implementation
}
}
내 클래스 1의 방법 항목 및 Class2의에 대한 방법 2 없으며 VICA 구절이 필요하면 내가 상황을 의미한다. 실제로 메서드는 파생 클래스에서 서로를 제외합니다.
'NotSupportedException' 또는'InvalidOperationException'을 던지는 것이이 컨텍스트에서 더 적합합니다. – Regent