I have a Replace method which can accept Xml node names as variables, the Replace will be evaluated on each row in the Xml getting the value of the node before it evaluates the expression. Therefore if some nodes don't exist the Replace will be evaluating on a null.
Given this condition is the following code is justified?
<chocolates>
<chocolate>
<name>Mars Bar</name>
</chocolate>
<chocolate>
<name>Bounty</name>
<type>Coconut</type>
</chocolate>
</chocolates>
Replace(type, 'C', 'c')
public string Replace(string a, string b, string c)
{
if (a == null) return null;
if (b == null || c == null) return a;
return a.Replace(b, c);
}