如何在下面的代码中使用“ StringComparison”属性?
string _strVariable = "New York";
var _countVar = nestList
.SelectMany(list => list)
.Count(city => string.Equals(city, _strVariable));
下面尝试过,但是它们不起作用,会引发错误。
var _countVar = nestList
.SelectMany(list => list)
.Count(city => string.Equals(city, _strVariable,StringComparison.OrdinalIgnoreCase));
var _countVar = nestList
.SelectMany(list => list)
.Count(city => string.Equals(city, _strVariable,StringComparer.OrdinalIgnoreCase));
为什么不能使用ToLower()
这样的字符串库函数>
var _countVar = nestList
.SelectMany(list => list)
.Count(city => city.ToLower() == _strVariable.ToLower);