title: How to get name of variable that was passed as parameter
body: <p>Is it possible to get get name of variable that was passed as parameter?</p>
  
  <p>As you asked me to explain why I need this, here is my explain. I'm building a testing framweork using selenium. Here is example where I need that name of variable that was passed as parameter.</p>
  
  <p>I have a page object with field:</p>
  
  <pre><code>[FindsBy(How = How.CssSelector, Using = "input[name='sample']")]
  private IWebElement SampleButton { get; set; }
  </code></pre>
  
  <p>I'm clicking it like:</p>
  
  <pre><code>Click(SampleButton, nameof(SampleButton));
  </code></pre>
  
  <p>Here is a body of <strong>Click</strong> function that u see above:</p>
  
  <pre><code>public void Click(IWebElement element, string elementName)
          {
              element.Click();
              Logger.Log("Click: '{0}'", elementName);
          }
  </code></pre>
  
  <p>Result: Button that was passed to function was clicked and in log file I have "Click: SampleButton"</p>
  
  <p>Now I'm looking how to change <strong>Click</strong> function that it woul be call like:</p>
  
  <pre><code>Click(SampleButton)
  </code></pre>
  
  <p>It would look like:</p>
  
  <pre><code>public void Click(IWebElement element)
          {
              element.Click();
              Logger.Log("Click: '{0}'", getNameOfVariableThatWasPassedToThisParameter(element));
          }
  </code></pre>
  
  <p>Expected result of <code>getNameOfVariableThatWasPassedToThisParameter(element)</code> will be <code>string = "SampleButton"</code></p>
  
  <p>I'm am using things like <code>SendKeys(SampleInput, nameof(SampleInput), valueToSet)</code> and it set value and log where it was set. So I just want <strong>to get rid of</strong> that <code>nameof(SampleInput)</code>. I want to <strong>reduce amount of variables than need to be passed to function.</strong> </p>