The life of a code monkey

Text

C# Nullable gotcha

Recently I ran into a interesting gotcha will System.Nullable<T>.

Below is some code that was run through the immediate window.

new Nullable<bool>() is bool
false
new Nullable<bool>(false) is bool
true
new Nullable<bool>(false) is Nullable<bool>
true
new Nullable<bool>() is Nullable<bool>
false
Posted on Monday, October 10 2011. Tagged with: CNullablegotcha.net
18
Notes
  1. today9201 liked this
  2. dotnetgeek posted this
Got a question or comment? Ask me.
Previous Next