title: How to determine if DataTable is null, not initialized
body: <p>I have a method that does some work on a DataTable e.g.</p>
  
  <pre><code>private void MyMethod(DataTable table)
  {
      if(table.Rows.Count &gt; 0)
      {
         //  do some work
      }
   }
  </code></pre>
  
  <p>However, if the method receives a null datatable from the application it serves I get an 'Object reference not set to an instance of an object' error.  </p>
  
  <p>I have also tried . . .</p>
  
  <pre><code>if(table.IsInitialized) { }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if(table != null) {  }
  </code></pre>
  
  <p>but I get the same error message.</p>
  
  <p>How do I test to see if the incoming datatable is instantiated and not null please?</p>
  
  <p>The DataTable is coming from a cast of a datagrid in a WinForms app i.e.</p>
  
  <pre><code>DataTable table = (DataTable)datagridview.DataSource;
  </code></pre>
  
  <p>So the issue arises if the original datagridview is empty.</p>