Reputation: 9224
I found this post that explains how to pass methods as parameters in C#.
What I need to know is how to return a method as the result of another method invocation.
method = DoSomething()
result = method()
Upvotes: 2
Views: 216
Reputation: 48476
you need to use either Action<T>
or Func<T>
Like this:
private Action<string> Returns(string user)
{
return () =>
{
Console.WriteLine("Hey {0}", user);
};
}
or this:
private Func<bool> TestsIsThirty(int value)
{
return () => value == 30;
}
Upvotes: 4
Reputation: 29213
Most probably you want your return type to be a Delegate
.
Upvotes: 2