This is because nullable types are implemented as a hack with generics. So,
your nullable float is actually a "value" with a flag to indicate if it is
null or not. And when you assign it to an object variable, it gets boxed,
and the object is not null!
This is very bad (totally counter intuitive). Last I heard was that MS is
changing this and that nullable will be implemented differently in the
release. But this needs confirmation.
Bruno.
"Yannick Létourneau" <YannickLtourneau@discussions.microsoft.com> a écrit
dans le message de news:
AB36297B-3764-4CFC-8ECB-746C4952868D@microsoft.com...
> Can someone explain to me why this code throws an exception ?
>
[quoted text clipped - 9 lines]
>
> Yannick L.
Yannick Létourneau - 14 Sep 2005 19:15 GMT
Thanks for the reply. I totally agree with you.
Do you have any pointers/links I could check to validate that this is indeed
something being addressed by Microsoft ?
Thanks.
> This is because nullable types are implemented as a hack with generics. So,
> your nullable float is actually a "value" with a flag to indicate if it is
[quoted text clipped - 23 lines]
> >
> > Yannick L.
Mattias Sjögren - 14 Sep 2005 21:09 GMT
>Do you have any pointers/links I could check to validate that this is indeed
>something being addressed by Microsoft ?
http://blogs.msdn.com/somasegar/archive/2005/08/11/450640.aspx
If you have access to the August CTP or September RC release of VS2005
you can verify it yourself.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.