title: Custom Attributes such as Displayname not listed with GetCustomAttribute
body: <p>I have some code to define custom attributes and then to read in the code,   it fails to work. To try and fix the problem I have gone back and tried to use DisplayName, however , I am still having the same issue GetCustomAttribute or GetCustomAttributes fails to list them. I have an example below.</p>
  
  <p>I have a DisplayName Attribute set in a class, for example...</p>
  
  <pre><code>class TestClass
   {
          public TestClass() { }
  
          [DisplayName("this is a test")]
          public long testmethod{ get; set; }
   }
  </code></pre>
  
  <p>I then have some code to list the DisplayName Attribute for each method in the class above.</p>
  
  <pre><code>TestClass testClass = new TestClass();
  
     Type type = testClass.GetType();
  
              foreach (MethodInfo mInfo in type.GetMethods())
              {
  
              DisplayNameAttribute attr = (DisplayNameAttribute)Attribute.GetCustomAttribute(mInfo, typeof(DisplayNameAttribute));
  
                     if (attr !=null)
                      {
                          MessageBox.Show(attr.DisplayName);   
  
                      }
  
  
              }
  </code></pre>
  
  <p>The problem is that there are no DisplayName Attributes listed, Above code compiles,  runs and doesn't display any messageboxes.</p>
  
  <p>I have even tried to use a for each loop with GetCustomAttributes, listing all the attributes for each method again the DisplayName Attribute is never listed, however, I do get the compilation attributes and other such system attributes. </p>
  
  <p>Anyone have any idea what I am doing wrong?</p>
  
  <p><strong>UPDATE- Many thanks to NerdFury for pointing out that I was using Methods and not Properties. Once changed every thing worked.</strong></p>