Manikkoth <Ma*******@discussions.microsoft.comwrote:
I came across an idiosyncrasy about nullable value types. According to the
documentation there are two valid syntax for nullable value types. One is
using the Nullable<Tgeneric and the other using nullable type modifier T?.
However, if you use the HasValue call without first assigning a null value to
a Nullable<Tgeneric instantiation you will get a compiler error "Use of
unassigned ... variable", whereas the type modifier based instantiation
doesn't give this error!
Could you post a short but complete program which demonstrates the
problem?
See
http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
Here's a sample program I've written:
using System;
class Test
{
static void Main()
{
int? x;
Nullable<inty;
Console.WriteLine (x.HasValue);
Console.WriteLine (y.HasValue);
}
}
That complains for both x and y.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too