Reputation: 1345
The following code fails to compile:
class MyClass<T> : where T : MyClass <T>{}
Is there any way to solve this? I have used the following workaround but I was wondering if there is a better way
class MyClass <T> : IMyClass where T : IMyClass {}
interface IMyClass {}
Upvotes: 1
Views: 173
Reputation: 217233
You need to put a colon after the class name only if you want to derive the class from a base class or implement an interface:
class MyClass<T> where T : MyClass<T>
// ↑
// no ':' here
Upvotes: 5