title: How can I detect if this dictionary key exists in C#?
body: <p>I am working with the Exchange Web Services Managed API, with contact data. I have the following code, which is <em>functional</em>, but not ideal:</p>
  
  <pre><code>foreach (Contact c in contactList)
  {
      string openItemUrl = "https://" + service.Url.Host + "/owa/" + c.WebClientReadFormQueryString;
  
      row = table.NewRow();
      row["FileAs"] = c.FileAs;
      row["GivenName"] = c.GivenName;
      row["Surname"] = c.Surname;
      row["CompanyName"] = c.CompanyName;
      row["Link"] = openItemUrl;
  
      //home address
      try { row["HomeStreet"] = c.PhysicalAddresses[PhysicalAddressKey.Home].Street.ToString(); }
      catch (Exception e) { }
      try { row["HomeCity"] = c.PhysicalAddresses[PhysicalAddressKey.Home].City.ToString(); }
      catch (Exception e) { }
      try { row["HomeState"] = c.PhysicalAddresses[PhysicalAddressKey.Home].State.ToString(); }
      catch (Exception e) { }
      try { row["HomeZip"] = c.PhysicalAddresses[PhysicalAddressKey.Home].PostalCode.ToString(); }
      catch (Exception e) { }
      try { row["HomeCountry"] = c.PhysicalAddresses[PhysicalAddressKey.Home].CountryOrRegion.ToString(); }
      catch (Exception e) { }
  
      //and so on for all kinds of other contact-related fields...
  }
  </code></pre>
  
  <p>As I said, this code <em>works</em>. Now I want to make it suck <em>a little less</em>, if possible.</p>
  
  <p>I can't find any methods that allow me to check for the existence of the key in the dictionary before attempting to access it, and if I try to read it (with <code>.ToString()</code>) and it doesn't exist then an exception is thrown:</p>
  
  <blockquote>
    <p>500<br/>
    The given key was not present in the dictionary.</p>
  </blockquote>
  
  <p>How can I refactor this code to suck less (while still being functional)?</p>