This might work for you:
class Base<T> where T : Base<T>
You can’t constrain T
to an open generic type. If you need to constrain T
to Base<whatever>
, you’ll need to construct something like:
abstract class Base { }
class Base<T> : Base where T : Base { ... }
More Related Contents:
- Is there a constraint that restricts my generic method to numeric types?
- Solution for overloaded operator constraint in .NET generics
- Generic constraints, where T : struct and where T : class
- How can I use interface as a C# generic type constraint?
- C# Generics won’t allow Delegate Type Constraints
- Is there a C# generic constraint for “real number” types? [duplicate]
- Why use generic constraints in C#
- Why does this generic constraint compile when it seems to have a circular reference
- Is there a generic constraint I could use for the + operator?
- Restricting a generic type parameters to have a specific constructor
- How to constrain generic type to must have a construtor that takes certain parameters?
- Can you use “where” to require an attribute in c#?
- What exactly is an “open generic type” in .NET? [duplicate]
- Generics in C#, using type of a variable as parameter [duplicate]
- A generic list of anonymous class
- Why isn’t ArrayList marked [Obsolete]?
- How do I override List’s Add method in C#?
- Collection of generic types
- C# 3.0 generic type inference – passing a delegate as a function parameter
- Why does IEnumerator inherit from IDisposable while the non-generic IEnumerator does not?
- ThreadStatic v.s. ThreadLocal: is generic better than attribute?
- What is ‘1 in Collection type Name
- C# – static types cannot be used as type arguments
- Can I have a variable number of generic parameters?
- Which C# method overload is chosen?
- Calling generic static method in PowerShell
- What is the equivalent of Java wildcards in C# generics
- Creating a generic method in C#
- C# generic methods, type parameters in new() constructor constraint
- Convert DataTable to Generic List in C#