title: C# - don't break a try catch block
body: <p>I want to set values that I read from a database to strings (using a <strong>SqlDataReader</strong>). I have a <strong>try-catch</strong> block to catch some System.DBNull that may come from the database table. And whenever those <em>nulls</em> appear I want to set a different value to that field. Those fields are then to be set to an object and then added to a list.</p>
  
  <p>The following code demostrates better my problem:</p>
  
  <pre class="lang-cs prettyprint-override"><code>while (reader.Read())
  {
      try
      {
          string originalfilename = (string)reader[0];
          string renamedfilename = (string)reader[1];
          string sheet = (string)reader[2];
          string version = (string)reader[3];
  
          AddDocument(originalfilename, renamedfilename, sheet, version);
      }
      catch (InvalidCastException e)
      {
          e.Source = "N/A";
      }
  }
  </code></pre>
  
  <p>In the example, if <strong>reader[2]</strong> is System.DBNull then I want that the <strong>sheet</strong> string to have <em>"N/A"</em>, but I want <strong>version</strong> to be set normally from <strong>reader[3]</strong> and AddDocument executed after.</p>
  
  <p>I am looking for a solution without many <em>if's</em>. I thought that <em>e.Source</em> would solve my problem but the <strong>try</strong> block breaks after the exception is caught.</p>
  
  <p>Thank you in advance.</p>