Date: 2022jan18
Language: C#
Keywords: comparison
Q. C#: case-insensitive string compare
A. Use String.Compare() with third parameter=true
public static bool ceq(string a, string b)
{
if (a == null && b == null) return true;
if (a == null || b == null) return false;
return String.Compare(a, b, true) == 0;
}
// Another way
public static bool ceq2(string a, string b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
return a.Equals(b, StringComparison.InvariantCultureIgnoreCase);
}