List<string> expectedResult = new List<string> { "article i", "article ii", "article iii" };
string result = Selenium.GetText("result_list");
if (expectedResult.Any(result.ToLower().Contains))
{
// do something
}
I get result = "Article I", but expectedResult.Any(result.ToLower().Contains) returns false. Not sure why ToLower() is not working?
Can anyone review my work, and let me know if I’m doing things right here?
It’s more efficient not to use
ToLowerin this case but theContainsoverload that takes aStringComparer.The reason is that
ToLowerwill create a (temporary) copy of the original string wheras theContainsoverload won’t: