There are a number of ways to compare strings. Are there performance gains by doing one way over another?
I\'ve always opted to compare strings like so:
Well MSDN states you shoul use the comparision function according to the task you need to perform:
The CompareTo method was designed primarily for use in sorting or alphabetizing operations. It should not be used when the primary purpose of the method call is to determine whether two strings are equivalent. To determine whether two strings are equivalent, call the Equals method.
So if its not about sorting and the retrun value is not important i would say one should use the:
first.Equals(second)
or if the comparison is culture specific for example in languages like in german:
String.Equals(first, second, StringComparison.CurrentCulture)
Take a look a these links:
How to: Compare Strings (C# Programming Guide)
String.CompareTo Method (Object)