'How to create a more restrictive generic constraint in inherited class
public class Foo<T> where T:struct, Enum, Iimmutable
public class Bar<T>:Foo<T> where T:Iimmutable //No
public class Bar:Foo<Iimmutable> //No
I thought this might be allowed, considering that the base class provides 3 options for constraints, and I need a more constrained derived class of just one of the matching constraints.
I get a compiler warning. It seems as if all Bar<Iimmutable> satisfy Foo<T> constraints. Can you suggest what to do, I need the functionality of the base class with the derived class constraint of Iimmutable...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
