Compiler Error CS0454
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Error CS0454 

Error Message

Circular constraint dependency involving 'Type Parameter 1' and 'Type Parameter 2'

This error arises because at some point one type parameter refers to another, and the second refers back to the first. To fix this error, break the circular dependency by removing one of the constraints. Note that the circular constraint dependency can be indirect.


The following code generates error CS0454.

// CS0554
using System;
public class GenericsErrors 
    public class G4<T> where T : T { } // CS0454

The following example demonstrates a circular dependency between two type constraints.

public class Gen<T,U> where T : U where U : T  // CS0454
© 2015 Microsoft