Somewhere in the back of my head a tiny voice is telling me "the C# code below smells".
private const string STR_ConnectionString = "ConnectionString";
private readonly string upperCaseConnectionString = STR_ConnectionString.ToUpperInvariant();
// a lot further on
string keyAttributeValue = keyAttribute.Value;
if (keyAttributeValue.ToUpperInvariant().StartsWith(upperCaseConnectionString))
{
// some C# code handling a key that starts with "ConnectionString"
}
The constant STR_ConnectionString
is used in other places in the code as well.
How to get rid of the smell?