I'm a little unclear on when/if the Value property on nullable types must be used when getting the value contained in a nullable type. Consider the following example:

int? x = 10;

Console.WriteLine("The value of 'x' is " + x.Value);
Console.WriteLine("The value of 'x' is " + x);

Both of these return the same value (10).

However, if I initially set x to null, the first Console.WriteLine throws an exception and the second one does not.

So, my question is this. What is the point of using the Value property? It doesn't appear to be needed to get the actual value (even if it's null) and will throw an exception if the value is indeed null.

c#
Edit
Report