title: Handling Null types from SQL in C#
body: <p>I am using the <code>SqlDataReader</code> to get values from an SQL table and assign them to their respective variables. But in my table, <code>int</code> and <code>double</code> type columns have null values. So when I try to read a <code>null</code> <code>int</code> and assign it to an <code>int</code> variable, it crashes.</p>
  
  <p>Here is how the values are being assigned to:</p>
  
  <pre><code>public int ID { get; set; }
  public int Map { get; set; }
  public int TypeID { get; set; }
  </code></pre>
  
  <p>And this is where they are being read:</p>
  
  <pre><code>while (objSqlDataReader.Read())
  {
      data= new data();
      emissiondata.ID = (int)objSqlDataReader["EFID"];
      emissiondata.Map = (int)objSqlDataReader["EFMappingID"];
      emissiondata.TypeID =(SqlInt32)objSqlDataReader["MobileTypeID"];
  </code></pre>
  
  <p>So if any of these is <code>null</code>, even when i'm debugging it, it crashes and doesn't continue.
  How do I handle the <code>null</code> values in SQL and how do I assign empty values to my <code>int</code> if it is <code>null</code>?</p>