Really funky C# compiler behavior with nullable literals?

Always produces 'false Managing to compile without errors isn't the same as not complaining :).

Not double. The result will always be the null value for the double?(aka Nullable) type. Oh, and both of the first two blocks should make the compiler complain, with warnings like this: Test.

Cs(7,19): warning CS0458: The result of the expression is always 'null' of type 'int? ' Test.Cs(12,13): warning CS0464: Comparing with null of type 'double? ' always produces 'false' Managing to compile without errors isn't the same as not complaining :).

Right I had accidentally turned off warnings. With warnings turned on I wouldn't even have to ask the question as the compiler explains everything in the warning. – bitbonk Sep 20 '10 at 22:04.

I = null + 1; // i. HasValue = false in this case if(10.0 > i) { } so you are actually trying to compare a non nullable type to a nullable type which doesn't have value. Double myDoubleValue = null + 1; doesn't compile because the type on the right hand is int?

And not double. Also is this question just out of curiosity in attempt to #%=^ the compiler or you are actually writing something like this in a real project?

Of course not. I had a typo in my code wich yielded wrong behavior. While debugging I discovered the typo and wondered why no one warned be about this.

Only to notice later on that I accidentally disabled the warnings tab in visual studio. – bitbonk Sep 20 '10 at 22:08.

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