Here the compiler enforces the T parameter of the Nullable<T> class to
be a non-nullable type, thus avoiding nested nullability tests on
instances of that type. This check has been introduced after .NET 2.0
beta2, because it lends to cleaner code. Before that, it was legal to
have a Nullable<String>, for example.
As the declaration of Nullable<T> implies, the T parameter must be a struct.

That is:

string? (equals to Nullable<String>) is not valid because String is a
class, not a struct.
int? (equals to Nullable<Int32>) is valid because Int32 is a struct, not
a class.

Also, given both your code and the text of the error message, I think
either the interface declaration or the error message are wrong: the
error message refers to A, while the interface declaration refers to X...

HTH

--
Efran Cobisi
http://www.cobisi.com

Mark Nicholls wrote:
Sorry to bombard with generic questions...

I've just come across

interface IA<X>
{
...
}

interface IB<X> : IA<X?> // yes the '?' is not a typo
{
}

it does compile...it gives

The type 'A' must be a non-nullable value type in order to use it as
parameter 'T' in the generic type or method 'System.Nullable<T>'

i.e. it understands what the T is....but I don't.

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to