更新时间:2023-02-04 23:18:35
如果要检查Name
是否包含搜索文本:
If you want to check to see if Name
contains the search text:
AllApplications.Where(x => x.Name.ToUpperInvariant().Contains(txtSearch.Text.ToUpperInvariant()))).ToList();
如果要检查是否相等:
AllApplications.Where(x => string.Equals(x.Name, txtSearch.Text, StringComparison.OrdinalIgnoreCase)).ToList();
在原始查询中,您正在检查x.Name
是否包含string.Compare
的结果.我认为您不是要这样做,因为 string.Compare
返回一个整数. string.Compare
主要用于确定排序顺序.
In your original query, you were checking to see if x.Name
contains the result of string.Compare
. I assume you weren't trying to do this, since string.Compare
returns an integer. string.Compare
is used primarily for determining sort order.