Share via


컴파일러 오류 CS0460

업데이트: 2007년 11월

오류 메시지

재정의 및 명시적 인터페이스 구현 메서드에 대한 제약 조건은 기본 메서드에서 상속되므로 직접 지정할 수 없습니다.
Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly

파생된 클래스의 일부인 제네릭 메서드가 기본 클래스의 메서드를 재정의하는 경우 재정의된 메서드에 대한 제약 조건을 지정할 수 없습니다. 파생된 클래스의 재정의 메서드는 기본 클래스에 있는 메서드의 제약 조건을 상속합니다.

예제

다음 샘플에서는 CS0460 오류가 발생하는 경우를 보여 줍니다.

// CS0460.cs
// compile with: /target:library
class BaseClass 
{
   BaseClass() { }
}

interface I
{
   void F1<T>() where T : BaseClass;
   void F2<T>() where T : struct;
   void F3<T>() where T : BaseClass;
}

class ExpImpl : I
{
   void I.F1<T>() where T : BaseClass {}   // CS0460
   void I.F2<T>() where T : class {}  // CS0460
}