Compiler Error CS0455
Type parameter 'Type Parameter Name' inherits conflicting constraints 'Constraint Name 1' and 'Constraint Name 2'
Two common ways to get this error are to set up constraints so that the type parameter derives from two non-related classes, or so that it derives from a class type or reference type constraint and a struct
type or value type constraint. To resolve this error, remove the conflict from your inheritance hierarchy.
Example
The following code generates error CS0455.
// CS0455.cs
using System;
public class GenericsErrors {
public class B { }
public class B2 { }
public class G6<T> where T : B { public class N<U> where U : B2, T { } } // CS0455
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for