title: Getting the name of a property in c#
body: <p>Given this class:</p>
  
  <pre><code>public class MyClass
  {
      public int MyProperty {get; set;}
  }
  </code></pre>
  
  <p>How will I be able to extract the name of <code>MyProperty</code> in code?</p>
  
  <p>For example, I am able to get the name of the class like this</p>
  
  <pre><code>typeof(MyClass).Name
  </code></pre>
  
  <p>How can I do something similar for the property?</p>
  
  <p>The reason for the question is that I want this particular code to be resistant against refactorizations of the names.</p>
  
  <p>EDIT: With resistant I mean that I want the code at the call site to be robust in the face of changes of the propertyname. I have some stuff that is using a string representation of the property name. Sorry for the poor phrasing.
  I did not include call site code in order to keep the problem clean and not wander off into other discussions on the nature of the call site code.</p>