如何在Func<>表达式中添加额外的参数?就像是:
Func<char, bool> myPredicate = (x) => (char.IsLetter(x) || x == 'X');
...
"abc".All(x => char.IsDigit(x) || myPredicate);
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个错误
运营商'||' 不能应用于'bool'和Func <char,bool>类型的操作数
你需要调用这样的myPredicate函数:
"abc".All(x => char.IsDigit(x) || myPredicate(x));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
70 次 |
| 最近记录: |