Consider the delegate for a generic A to B function:
public delegate B Fun<A, B>(A x);
I can then write a function that accepts and invokes the Fun delegate:
public static B invokeFun<A, B>(A x, Fun<A, B> f) { return f(x); }
(Never mind whether it is wise to write invokeFun.)
Can I write invokeFun without naming the Fun delegate? I would expect something like this to work, but it doesn’t:
public static B invokeFun<A, B>(A x, B (A) f) { return f(x); }
No, there aren’t.
The closest you can get is the two generic delegate families in .NET 3.5:
FuncandAction. Obviously they’re not actually present in .NET 2.0 (exceptAction<T>), but they’re trivial to write – and indeed I’ve done so for you 🙂Personally I’m glad the ‘uber-short’ syntax is invalid – I find it harder to understand than the normal ‘here’s the type, here’s the name’ syntax for the parameter.