QuickTip: Comparing strings in c# ignoring case? ToLower() is not the answer.

When doing a code review I often see code comparing two strings where the developer wants the comparison to be case insensitive and chose to use ToLower() or ToUpper() and == to get the job done. However because the dot net framework handles different cultures just using ToUpper/Lower could produce unpredictable results depending on the config of the machine your code is running on. Instead you should use the OrdinalIgnoreCase option on string....

January 11, 2016 · 1 min · 99 words · Alastair Crabtree