title: How to retrieve Data Annotations from code? (programmatically)
body: <p>I'm using <code>System.ComponentModel.DataAnnotations</code> to provide validation for my Entity Framework 4.1 project.</p>
  
  <p>For example:</p>
  
  <pre><code>public class Player
  {
      [Required]
      [MaxLength(30)]
      [Display(Name = "Player Name")]
      public string PlayerName { get; set; }
  
      [MaxLength(100)]
      [Display(Name = "Player Description")]
      public string PlayerDescription{ get; set; }
  }
  </code></pre>
  
  <p>I need to retrieve the <code>Display.Name</code> annotation value to show it in a message such as <em>The chosen "Player Name" is Frank.</em></p>
  
  <p>=================================================================================</p>
  
  <p>Another example of why I could need to retrieve annotations:</p>
  
  <pre><code>var playerNameTextBox = new TextBox();
  playerNameTextBox.MaxLength = GetAnnotation(myPlayer.PlayerName, MaxLength);
  </code></pre>
  
  <p>How can I do that?</p>