Combine Multiple Predicates

后端 未结 7 717
眼角桃花
眼角桃花 2020-12-01 03:32

Is there any way in c# .NET 2.0! to combine multiple Predicates?

Let\'s say I have the following code.

List names = new List

        
7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 04:01

    Having used this pattern extensively with the above 'params' array method, I was intrigued by recently learning about the Multicast delegate. Since delegates inherently support a list (or multicast), you can skip the params[] pattern and just supply a single delegate to your Test() function. You will need to call GetInvokationList on the supplied Predicate<>. See this: Multicast delegate of type Func (with return value)?

提交回复
热议问题