Comparing two strings, ignoring case in C# [duplicate]

Which of the following two is more efficient? (Or maybe is there a third option that’s better still?)

string val = "AStringValue";

if (val.Equals("astringvalue", StringComparison.InvariantCultureIgnoreCase))

OR

if (val.ToLowerCase() == "astringvalue")

?

8 Answers
8

Leave a Comment