Is Nullable DateTime work correct?

Yes, it's correct. From the documentation The text representation of the value of the current Nullable object if the HasValue property is true, or an empty string ("") if the HasValue property is false. Note also that Nullable.

Equals and Nullable. GetHashCode do not throw in this case but that Nullable. GetType does throw.

This is because Object. Equals, Object. GetHashCode and Object.

ToString are overridden for Nullable but that Object. GetType is not (because it can not be as it is not marked as virtual).

Ok, thanks for you answer. But how you think is it correct way? Because if you will use String tmp = null; tmp.ToString() it will rise exception – Andrei Andrushkevich Dec 28 '10 at 15:40 Because a nullable type with HasValue as false is not a null reference.

From a conceptual perspective, a nullable type represents a value type with the possibility of the value being "missing. " We use null to represent when the value is missing, but this is not the same as a null reference. Note that tmp.

Value will throw in the case of tmp being an instance of a nullable type with HasValue as false. The value is missing so trying to obtain said value should and does throw accordingly. – Jason Dec 28 '10 at 15:44.

Still is a Value-type. If you try ToString() on any null-ed Reference-type you of course get an exception: var sb = new Stringbuilder("foo"); sb = null; string s = sb.ToString(); // null reference exception But DateTime? Is not a Reference-type and so you will never get a null-ref exception.

The empty string was a design decision.

3 I assume they were expecting a NullReferenceException. – ChaosPandion Dec 28 '10 at 15:29 NUll reference exception – Andrei Andrushkevich Dec 28 '10 at 15:29 1 @galimy: a null reference exception is thrown when a null reference is dereferenced. A null value type is by definition not a reference, so it wouldn't make any sense to throw a null reference exception unless the null value type was converted to a null reference by boxing.

– Eric Lippert Dec 28 '10 at 16:05.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions