Aller au contenu

Case-insensitive comparison through ToLower/ToUpper (CA1862)

Ce contenu n’est pas encore disponible dans votre langue.

Key dotnet.performance.case-insensitive-compare · Severity warning · Category performance

Microsoft analyzer CA1862. Flags ToLower/ToUpper used to compare strings case-insensitively. Each call allocates a new string; the StringComparison overloads compare in place.

if (email.ToLower() == other.ToLower())
Merge();
if (string.Equals(email, other, StringComparison.OrdinalIgnoreCase))
Merge();