How can I pass additional parameters to predicate functions?
No, but you can do this:
public Comparison<T> MakeComparison<T>(object extraParameter)
{
return
delegate(T x, T y)
{
// do comparison with x, y and extraParameter
}
}
Simple capture the variables you need when you declare the predicate. Eg:
int i = 0, j = 10;
array.Sort(x => x > i && x < j ? 1 : -1);