Is it possible to pass in the strongly typed name of a method as a lambda expression without also providing the parameters and/or parentheses?
For example, if I have the following method:
public class CalleeClass
{
public void MethodA(obj param1, obj param2)
{
...
}
}
I would like to call this method elsewhere via:
return new MyClass<CalleeClass>(c => c.MethodA); //Note: no ()'s or arguments
Where MyClass would be responsible for, say, MVC routing using the method name as the target. The goal here is that we want to be able to use strongly typed views via controller methods, and I don't want to have to provide "dumb" parameters that don't get used.
Presently, I am using code similar to the following in order to use the method names, but this style still requires passing in fake arguments and/or parentheses.
public void MyClass<T>(Expression<Action<T>> action)
{
var methodName = (action.Body as MethodCallExpression).Method.Name;
}
EDIT: Sorry for the confusion, but I initially tried to simplify the issue by only including what I thought you'd need, and in doing so left out some key info. The ultimate goal here is to have MyClass receive a generic type + lambda expression, and the lambda expression can pass in the strongly typed method name without instantiating an object. -MB