title: C# : Displaying field metadata using System.Reflection.GetFields()
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/95910/find-a-private-field-with-reflection">Find a private field with Reflection?</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to display a class's field names using the System.Reflection.GetFields() method.</p>
  
  <p>Problem is it only works when the fields are declared as "public". 
  For example :</p>
  
  <pre><code>class Element
  {
      private String id;
      private string a;
      private string b;
      private int c;
      private Dictionary&lt;String, String&gt; dict;
  
      public Element(String id)
      {
          this.id= id;
      }}
  </code></pre>
  
  <p>When I try calling the System.Reflection.GetFields() method, it doesn't work (it returns an empty array). However, if I change the visibility of the fields to "public", it works..</p>
  
  <p>Anyone know how I can get it to work without having to make it public? </p>
  
  <p>Thanks</p>