Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 if 语句,我想检查一个字符串是否包含 a 的任何项目list<string>。
list<string>
if (str.Contains(list2.Any()) && str.Contains(ddl_language.SelectedValue)) { lstpdfList.Items.Add(str); }
正确的公式是
list2.Any(s => str.Contains(s))
这被读作“确实包括任何包含?list2的字符串”。sstrs
list2
s
str
你可以使用这个:
if (myList.Any(x => mystring.Contains(x))) // ....