This documentation is archived and is not being maintained.

Compiler Error CS0454

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
{
}
Show: