I want to get the variable name of an argument passed into a method.
// Somewhere in the code
int myNumber = 1;
Method(myNumber);
...
public void Method(int number)
{
// Here I want to somehow get "myNumber" as well as access the value '1'.
}
I haven't had any success finding an answer to this question. Many answers says no, but that is back when C# 6 was the latest version. Maybe there is a solution today?
I imagine that passing by reference ref
could be relevant, as that at least ensures that a variable is passed in the method, and not just the value.