title: C# Linq statement for each
body: <p>I want to write the following statement:</p>
  
  <pre><code>things.ToList().ForEach(x =&gt;
  {
      x.thingname = x.thingname.Replace("oldvalue", "newvalue");
      x.thingname2 = x.thingname2.Replace("oldvalue", "newvalue");
  });
  </code></pre>
  
  <p>This code works fine and replace works successfully.  However if <code>x.thingname</code> is null the code errors.  How can I check for null values before doing the replace?</p>