title: How to retrieve an object's Property name/value pairs on a custom object?
body: <p>I have a custom object with varying datatypes for each property.
  I would like to be able to do something like: </p>
  
  <pre><code>    public void evalCI(configurationItem CI)
       {
      foreach (PropertyInformation n in CI)
         {
          Response.Write(n.Name.ToString() + ": " + n.Value.ToString() + "&lt;/br&gt;");
         }
       }
  </code></pre>
  
  <p>My custom object is:</p>
  
  <pre><code>public class configurationItem : IEnumerable
  
  {
      private string serial;
      private string model;
      private DateTime? wstart;
      private DateTime? wend;
      private Int32 daysLeft;
      private string platform;
      private string productVersion;
      private string manufacturer;
      private bool verificationFlag;        
  
      IEnumerator IEnumerable.GetEnumerator()
      {
          return (IEnumerator)GetEnumerator();
      }
  
      public string Serial
      {
          set { serial = value; }
          get { return serial; }
      }
      public string Model
      {
          set { model = value; }
          get { return model; }
      }
      public DateTime? Wstart
      {
          set { wstart = value; }
          get { return wstart; }
      }
      public DateTime? Wend
      {
          set { wend = value; }
          get { return wend; }
      }
      public Int32 DaysLeft
      {
          set { daysLeft = value; }
          get { return daysLeft; }
      }
      public string Platform
      {
          set { platform = value; }
          get { return platform; }
      }
      public string ProductVersion
      {
          set { productVersion = value; }
          get { return productVersion; }
      }
      public string Manufacturer
      {
          set { manufacturer = value; }
          get { return manufacturer; }
      }
      public bool VerificationFlag
      {
          set { verificationFlag = value; }
          get { return verificationFlag; }
      }
  </code></pre>
  
  <p>My expected output would be:</p>
  
  <p>-Serial: 1234567</p>
  
  <p>-Model: Mustang</p>
  
  <p>-Wstart: 12/12/2005</p>
  
  <p>-Wend: 12/11/2006</p>
  
  <p>-DaysLeft: 0</p>
  
  <p>-Platform: Car</p>
  
  <p>-ProductVersion: GT</p>
  
  <p>-Manufacturer: Ford</p>
  
  <p>-VerificationFlag: true</p>
  
  <p>At first I was getting an error that GetEnumerator() had to be implemented to use a foreach loop.  The problem I keep running into is that all of the examples of Indexed Properties are of a single property with an indexable list, instead of an index for each property in the object. I was able to get intellisense to give me methods for PropertyInfo by adding: </p>
  
  <pre><code>    IEnumerator IEnumerable.GetEnumerator()
      {
          return (IEnumerator)GetEnumerator();
      }
  </code></pre>
  
  <p>However, the 2nd GetEnumerator() throws:
  Compiler Error Message: CS0103: The name 'GetEnumerator' does not exist in the current context.</p>
  
  <p>What am I missing here? How do I modify my object to give me the results I expect from evalCI()?</p>