I want to write the following statement:
things.ToList().ForEach(x =>
{
x.thingname = x.thingname.Replace("oldvalue", "newvalue");
x.thingname2 = x.thingname2.Replace("oldvalue", "newvalue");
});
This code works fine and replace works successfully. However if x.thingname
is null the code errors. How can I check for null values before doing the replace?