The code:
Console.WriteLine(result);
Is calling the "ToString()" method on the "result" variable. So its
equivalent of you saying:
Console.WriteLine(result.ToString());
Now, if you look at the internal implementation of the "ToString()" method
on the "Nullable" variable type (using Reflector) is implemented the
following way:
public override string ToString()
{
if (!this.HasValue)
{
return "";
}
return this.value.ToString();
}
So as you can see, you were calling the "Value" property, you just didn't
know you were doing it.
"Tony Johansson" <jo*****************@telia.comwrote in message
news:gl**************@newsb.telia.net...
Hello!
What purpose has this Value propery on nullable types because it possible
to display their value without using it.
For example:
int? intNullable1 = 3;
int? intNullable2 = 5;
Console.WriteLine(result); // This display 8
Console.WriteLine(result.Value); // This also display 8 the same
So I can't see any point in using this Value property on nullable types or
have I missed something here perhaps
that makes the Value property useful to have?
//Tony