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 been verified not to be null)
if (a.ToLower() == b.ToLower())
However, using Reflector, I've seen this a few times in the .NET Framework:
// (arg three is ignoreCase)
if (string.Compare(a, b, true) == 0)
I tested which is faster, and the ToLower() beat Compare() everytime with the strings I used.
Is there a reason why to Compare() instead of ToLower()? Something about different CultureInfo? I'm scratching my head.