title: What is the difference between null and System.DBNull.Value?
body: <p>Is there any difference between null and System.DBNull.Value? If yes, what is it?</p>
  
  <p>I noticed this behavior now - </p>
  
  <pre><code>while (rdr.Read())
  {
      if (rdr["Id"] != null) //if (rdr["Id"] != System.DBNull.Value)  
      {
          int x = Convert.ToInt32(rdr["Id"]);
      }
  }
  </code></pre>
  
  <p>While I retrieve data from the database using a sql datareader, though there is no value returned <code>if(rdr["Id"] != null)</code> returned <code>true</code> and eventually threw an exception for casting a null as integer. </p>
  
  <p>But, this if I use <code>if (rdr["Id"] != System.DBNull.Value)</code> returns <code>false</code>.</p>
  
  <p>What's the difference between null and System.DBNull.Value? </p>