Is there a C# case insensitive equals operator?

GateKiller picture GateKiller · Mar 10, 2009 · Viewed 117.3k times · Source

I know that the following is case sensitive:

if (StringA == StringB) {

So is there an operator which will compare two strings in an insensitive manner?

Answer

John Feminella picture John Feminella · Mar 10, 2009

Try this:

string.Equals(a, b, StringComparison.CurrentCultureIgnoreCase);