title: Testing if an Object is Nothing/null in VB.NET vs C#
body: <p>I'm converting some C# code to VB.NET.  I have a simple dictionary-like data structure that contains name/value pairs.  The value element is of type Object.  My C# code looks like this</p>
  
  <pre><code>if(x.Value != null)
    // 1: Store x.Value in database
  else
    // Sore DBNULL.Value in database
  </code></pre>
  
  <p>As expected, if x.Value happens to be a boolean of value false, code block 1 above executes.</p>
  
  <p>However, the equivalent VB.NET code will fall through to the else block on a Boolean of False</p>
  
  <pre><code>If x.Value Is Not Nothing Then
    ' Store x.Value in database
  Else
    ' We land here if x.Value is a Boolean with a value of False and incorrectly store DBNULL.Value in database
  EndIF
  </code></pre>
  
  <p>VB apparently thinks a Boolean with a False value is equivalent to Nothing.
  I'll keep my comments about VB to myself, but is there a non-convoluted way, i.e. without using reflection, to work around this problem?</p>
  
  <p>Edit: my original VB code was actually</p>
  
  <pre><code>If x.Value &lt;&gt; Nothing
  </code></pre>
  
  <p>That worked as described.</p>
  
  <pre><code>If x.Value IsNot Nothing
  </code></pre>
  
  <p>works correctly.  Thanks Steve.</p>