My code was failing to do a successful comparison between two similar looking strings.
I was trying to match the Taxonomy terms to find a matching term. The following value comparison might look equal but looking it closely you would say there is a bit of difference
Nut & Fruit = Nut & Fruit
The two ampersand characters are different, the one on the left was from the termset, while the one on the right from a single text field in a list.
A quick resolution was to slightly modify my code to take care of this special scenario
if (termVlaue.Contains("&") && term.Name.Contains("&"))
{
if (term.Name.Replace("&", "&").Equals(termVlaue))
return term;
}
else
{
if (term.Name.Equals(termVlaue))
return term;
}