Let\'s say I have two strings: a and b. To compare whether a and be have the same values when case is ignored, I\'ve always used:
// (Assume a and b have bee
When comparing strings you should always use an explicit StringComparison member. The String functions are somewhat inconsistent in how they choose to compare strings. The only way to guarantee the comparision used is to a) memorize all of them (this includes both you and everyone on your team) or b) use an explicit comparison for every function.
It's much better to be explicit and not rely on group knowledge being perfect. Your teammates will thank you for this.
Example:
if ( StringComparison.OrdinalIgnoreCase.Equals(a,b) )
Using ToLower for comparison has 2 problems I can think of off the top of my head