Skip to content

Latest commit

 

History

History
29 lines (25 loc) · 1.01 KB

cs0450.md

File metadata and controls

29 lines (25 loc) · 1.01 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Compiler Error CS0450
Compiler Error CS0450
07/20/2015
CS0450
CS0450
8eb0e98b-d7a1-49a7-8e55-36e2eb0057ff

Compiler Error CS0450

'Type Parameter Name': cannot specify both a constraint class and the 'class' or 'struct' constraint

If a type parameter is constrained by the struct type constraint, it is logically contradictory for it to also be constrained by a specific class type, since struct and class are mutually exclusive categories. If a type parameter is constrained by a specific class type constraint, then it is by definition constrained by the class type constraint, and so specifying the class type constraint is redundant.

Example

// 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 { }  
}