title: How to check if a Datatable is Null or Nothing
body: <p>How can I check if a <code>DataTable</code> has never been set, meaning it will be <code>Null</code> or <code>Nothing</code>? I don't mean an empty <code>DataTable</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>Dim dt As DataTable = TryCast(Session("dt"), DataTable)
  
  If dt.Rows.Count &lt;&gt; 0 Then
      'Do something !
  End If 
  </code></pre>
  
  <p>If <code>Session("dt")</code>has never been set or is lost in memory for some reason, <code>dt.Rows.Count &lt;&gt; 0</code> will throw this exception:</p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object.</p>
  </blockquote>