Export (0) Print
Expand All
Expand Minimize

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.

Example

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

Community Additions

ADD
Show:
© 2014 Microsoft