title: Is there a better way to get a variable's name as a string in .NET 4.5?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9801624/get-name-of-a-variable-or-parameter">get name of a variable or parameter</a>  </p>
  </blockquote>
  
  
  
  <p>I want to be able to get a variable's name as a string.</p>
  
  <p>This can be achieved effectively by <a href="http://ivanz.com/2009/12/04/how-to-avoid-passing-property-names-as-strings-using-c-3-0-expression-trees/" rel="nofollow noreferrer">using a parameterless lambda expression</a>. However, this has a performance overhead, and it's not built-in functionality.</p>
  
  <p>.NET 4.5 has provided  <a href="http://awkwardcoder.blogspot.com.au/2012/07/callermembername-not-that-great-for.html" rel="nofollow noreferrer"><code>CallerMemberNameAttribute</code></a> to provide a caller's name as a method argument. This gives us a built-in and better (in some cases) way to do this for specific situations.</p>
  
  <p><strong>.NET 4.5 has provided an improvement in this area for a specific context. Is there now also a better^ means to get any variable's name as a string?</strong></p>
  
  <p>As requested, here's a general usage example of what I'd like to achieve:</p>
  
  <pre><code>//Assume 'myVariable' is a local variable, member variable, static member variable, constant, parameter or even a property.
  string myVariableName = ...; //This should get the string name of myVariable
  </code></pre>
  
  <p>^By better, I mean faster, not requiring reflection, built-into .NET or more elegant, but preferably a combination of these.</p>