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:
I generally use String.Compare with the overload that takes a StringComparison parameter, because then I can be absolutely explicit about whether or not the comparison is case- and culture-sensitive. This needs .NET 2.0 or later.
The fastest is StringComparison.Ordinal (or StringComparison.OrdinalIgnoreCase if case-insensitive) for comparisons that are not culture-sensitive.
The problem with using == is that it's not clear that the author has considered case- and culture-sensitivity.
There's a good MSDN article on the subject here.