I am trying to use a group of methods in a lambda expression, for example:
public class Foo { public void Hello(string s) { } }
void Test()
{
Func<Foo, Action<string>> a = foo => foo.Hello;
}
When I change the return type Helloto int, however, I get
'Bar.Hello (string)' has the wrong return type.
I tried playing with Funcinstead Action, but this prevents me from using the method group syntax.
Any ideas?
(My goal, fwiw, is to be able to reference multiple methods that have different return types and many string arguments. I'm not even going to call them - I just want to reflect their attributes. Like lambda security, however, instead of just entering method name strings.)
. Action<string>: int, . -
void Set<T>(Func<Foo, Func<string, T>> a) { }
void Test() { Set(foo => foo.Hello); }
- T ( , ?).
? - , .