title: Using reflection in ToString method
body: <p>I'm trying to clean up my class using reflection. </p>
  
  <pre><code>private List&lt;String&gt; centers = new List&lt;String&gt;();
  private List&lt;String&gt; leftWingers = new List&lt;String&gt;();
  private List&lt;String&gt; rightWingers = new List&lt;String&gt;();
  private List&lt;String&gt; defencemen = new List&lt;String&gt;();
  private List&lt;String&gt; goalies = new List&lt;String&gt;();
  private List&lt;String&gt; bench = new List&lt;String&gt;();
  
  public List&lt;String&gt; Centers { get { return centers; } set { centers = value; } }
  public List&lt;String&gt; LeftWingers { get { return leftWingers; } set { leftWingers = value; } }
  public List&lt;String&gt; RightWingers { get { return rightWingers; } set { rightWingers = value; } }
  public List&lt;String&gt; Defencemen { get { return defencemen; } set { defencemen = value; } }
  public List&lt;String&gt; Goalies { get { return goalies; } set { goalies = value; } }
  public List&lt;String&gt; Bench { get { return bench; } set { bench = value; } }
  
  public String ToString()
  {
      String output = "";
  
      System.Reflection.PropertyInfo[] properties = this.GetType().GetProperties();
  
      foreach (System.Reflection.PropertyInfo property in properties)
      {
          int count = 0;
          foreach (String value in property)
          {
              count++;
              output += "C" + count + ": " + value + System.Environment.NewLine;
          }
  
      }
  }
  </code></pre>
  
  <p>This will not work. I cant seem to be able to loop over items of each property because they are collections. Is there a way to get the contents of the String Lists from the PropertyInfo object?</p>