Nullable<int> intNullable = null;//this is ok since `Nullable<T> where T : struct`
However Nullable<Nullable<int>> is NOT OK although Nullable<int> is a struct.
How is this possible?
Nullable<int> intNullable = null;//this is ok since `Nullable<T> where T : struct`
However Nullable<Nullable<int>> is NOT OK although Nullable<int> is a struct.
How is this possible?
There is special language support for Nullable<T>, in numerous ways, one of which is that Nullable<Nullable<T>> is not valid. You could not create your own custom generic struct that could have any other struct except itself as the generic argument. The generic constraint function of C# just isn't powerful enough to do it.
Also note that the error message does not say that Nullable<int> isn't a struct, it says that it must be a non-nullable struct. Nullable<int> isn't a non-nullable struct. It's a nullable struct.