Share via


컴파일러 오류 CS0450

업데이트: 2007년 11월

오류 메시지

'Type Parameter Name': constraint 클래스와 'class' 또는 'struct' 제약 조건을 둘 다 지정할 수는 없습니다.
'Type Parameter Name': cannot specify both a constraint class and the 'class' or 'struct' constraint

struct와 class는 함께 사용할 수 없으므로 형식 매개 변수가 struct 형식 제약 조건의 제약을 받는 경우 특정 클래스 형식에 의해 다시 제약을 받는 것은 논리적으로 맞지 않습니다. 형식 매개 변수가 특정 클래스 형식 제약 조건에 의해 제약을 받는 경우 이는 정의에 따라 클래스 형식 제약 조건의 제약을 받는 것이므로 또다시 클래스 형식 제약 조건을 지정할 필요가 없습니다.

예제

// CS0450.cs
// compile with: /t:library
public class GenericsErrors 
{
    public class B { }
    public class G3<T> where T : struct, B { } // CS0450
// To resolve, use the following line instead:
// public class G3<T> where T : B { }
}