Lets say I have a method with the following signature:
public void MyMethod(Func<int> expression)
{
// Does work
}
And I call this method as follows:
int intProperty = 7;
MyMethod(() => intProperty);
Is their some way that I could call this method without using the lambda? So I want it to look like this:
MyMethod(intProperty);
It does not matter to me if the method signature has to change - I am kind of counting on that. The reason I am trying to do this is because you can inspect additional information about the initial property when its passed in as a function that I need to be able to access.
I don't believe that using Reflection inside of MyMethod would work here, as I want information about the original parameter. Their are ways of getting information such as its name from a function, which is what I want to be able to retrieve. I am already able to do this. So, in the example above, MyMethod would be able to tell that the name of the property that was passed in was named intProperty.
NOTE: This is a simplified example. I am well aware I could just pass in the property if that's all I wanted. BUT I want additional information about the original property that the Func is capturing here, such as its original name.