Share via


컴파일러 오류 CS0080

업데이트: 2007년 11월

오류 메시지

제네릭이 아닌 선언에는 제약 조건을 사용할 수 없습니다.
Constraints are not allowed on non-generic declarations

문제의 구문은 제약 조건을 형식 매개 변수에 적용하기 위해 제네릭 선언에서만 사용해야 할 수도 있습니다. 자세한 내용은 제네릭(C# 프로그래밍 가이드)을 참조하십시오.

다음 샘플에서는 MyClass가 제네릭 클래스가 아니고 Foo가 제네릭 메서드가 아니기 때문에 CS0080 오류가 발생합니다.

namespace MyNamespace
{
    public class MyClass where MyClass : System.IDisposable // CS0080    //the following line shows an example of correct syntax
    //public class MyClass<T> where T : System.IDisposable
    {
        public void Foo() where Foo : new() // CS0080
        //the following line shows an example of correct syntax
        //public void Foo<U>() where U : struct
        {
        }
    }

    public class Program
    {
        public static void Main()
        {
        }
    }
}