I wrote my own Predicate class for .NET 1.1 which allowed composite
predicates using operator overloading...
for example:
Predicate p1 = {...};
Predicate p2 = {...};
Predicate p1andp2 = ~(p1 ^ p2); // ^ is the AND operator in logic notation
which is requivalent to:
Predicate p1andp2 = delegate(object o) { return !(p1(o) && p2(o)); };
Predicates in .NET/C# 2.0 are delegates, not a class like my implementation
so it's not possible (using C#) to add overloaded operators to the Predicate
delegate. There is no such limitation in the runtime or IL.
What I would like to see is Microsoft add logical compositing operators for
the Predicate delegate in Whidbey. Predicates have a potential to be used
pretty much everywhere where a boolean decision needs to be made (for
flexibility reasons, it can/should replace bool in many areas of the BCL)
and being able to combine many distinct predicates into a single predicate
with an easy to use syntax would be nice....
^Tum