다음을 통해 공유


컴파일러 오류 CS0452

업데이트: 2007년 11월

오류 메시지

'type name' 형식을 'identifier of generic' 메서드 또는 제네릭 형식에서 'parameter name' 매개 변수로 사용하려면 참조 형식이어야 합니다.
The type 'type name' must be a reference type in order to use it as parameter 'parameter name' in the generic type or method 'identifier of generic'

이 오류는 참조 형식 제약 조건을 가진 메서드 또는 제네릭 형식에 struct 또는 int 같은 값 형식을 매개 변수로 전달하는 경우에 발생합니다.

예제

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

// CS0452.cs
using System;
public class BaseClass<S> where S : class { }
public class Derived1 : BaseClass<int> { } // CS0452
public class Derived2<S> : BaseClass<S> where S : struct { } // CS0452