title: converting string to datetime in C# on null value exception
body: <p>I use the below code</p>
  
  <pre><code> extensionRequest[i].EndDate = DateTime.Parse(dsResult.Tables[0].Rows[i]["ActualEndDate"].ToString());
   extensionRequest[i].ExtendedEndDate = DateTime.Parse(dsResult.Tables[0].Rows[i]["ExtendedEndDate"].ToString());
   extensionRequest[i].ReceivedDate =Convert.ToDateTime(dsResult.Tables[0].Rows[i]["dReceivedOn"].ToString());
  </code></pre>
  
  <p>this works fine when values are coming from the DB
  but when <code>NULL</code> values are returned it throws an exception!!</p>
  
  <p>Should i check values for all three values like the code below</p>
  
  <pre><code>if (dsResult.Tables[0].Rows[i]["dReceivedOn"].ToString()==null){
  extensionRequest[i].ReceivedDate="";
  }
  else{
  extensionRequest[i].ReceivedDate =Convert.ToDateTime(dsResult.Tables[0].Rows[i]["dReceivedOn"].ToString());
  }
  </code></pre>
  
  <p>or i should assign all dates to null on exception?!</p>
  
  <p>is there any other way to do in single line? like <code>tryparse</code> or something?</p>