A
Aamir Mahmood
Hi
I am unable to access the HasValue and Value properties in an Nullable
object.
int? i = 9;
object value = i;
if ((value as Nullable).HasValue) {
...
}
It does not compile. VS2005 says "System.Nullable does not contain a
definition of HasValue".
I want to achieve this to make just one function which can handle various
nullables like int?, decimal?, long? etc.
However, following code compile and runs OK for me.
int? i = 9;
if (i.HasValue) {
...
}
MSDN Says:
Fundamental Properties:
The two fundamental members of the Nullable structure are the HasValue and
Value properties. If the HasValue property for a Nullable object is true,
the value of the object can be accessed with the Value property.
Any ideas?
Thanks.
AM
I am unable to access the HasValue and Value properties in an Nullable
object.
int? i = 9;
object value = i;
if ((value as Nullable).HasValue) {
...
}
It does not compile. VS2005 says "System.Nullable does not contain a
definition of HasValue".
I want to achieve this to make just one function which can handle various
nullables like int?, decimal?, long? etc.
However, following code compile and runs OK for me.
int? i = 9;
if (i.HasValue) {
...
}
MSDN Says:
Fundamental Properties:
The two fundamental members of the Nullable structure are the HasValue and
Value properties. If the HasValue property for a Nullable object is true,
the value of the object can be accessed with the Value property.
Any ideas?
Thanks.
AM