我正在寻找像LINQ这样的方法List.Exists(predicate).
bool exists = mylist.Exists(p => p.Name == "Kamila");
bool exists = collection.??????(p => p.Name == "Kamila");
Run Code Online (Sandbox Code Playgroud)
使用.Any方法:
//Will return true (and stop future iteration the moment the predicate is met)
//Otherwise false
bool exists = collection.Any(p => p.Name == "Kamila");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
444 次 |
| 最近记录: |