Share via


컴파일러 오류 CS0314

업데이트: 2007년 11월

오류 메시지

제네릭 형식 또는 메서드 'name'에서 'type1' 형식을 형식 매개 변수 'name'(으)로 사용할 수 없습니다. 'type1'에서 'type2'(으)로의 boxing 변환 또는 형식 매개 변수 변환이 없습니다.
The type 'type1' cannot be used as type parameter 'name' in the generic type or method 'name'. There is no boxing conversion or type parameter conversion from 'type1' to 'type2'.

제네릭 형식에서 제약 조건이 있는 형식 매개 변수를 사용하면 새 클래스는 이러한 동일한 제약 조건도 충족해야 합니다.

이 오류를 해결하려면

  • 다음 예제에서는 where T : ClassConstraint를 클래스 B에 추가합니다.

예제

다음 코드에서는 CS0314 오류가 발생하는 경우를 보여 줍니다.

// cs0314.cs
// Compile with: /target:library
public class ClassConstraint { }

public class A<T> where T : ClassConstraint
{ }

public class B<T> : A<T> //CS0314
{ }

// Try using this instead.
public class C<T> : A<T> where T : ClassConstraint
{ }

참고 항목

참조

형식 매개 변수에 대한 제약 조건(C# 프로그래밍 가이드)