title: Get a complete string representation of an object (like in the Immediate Window in Visual Studio)
body: <p>Given the following example class:</p>
  
  <pre><code>public class MyClass
  {
      public string S { get; set; }
      public int I { get; set; }
      public DateTime D { get; set; }
      private float F { get; set; }
      private long l;
  
      public MyClass()
      {
          S = "foo";
          I = 42;
          D = new DateTime(2011, 11, 11);
          F = 3.14f;
          l = 12435;
      }
  }
  </code></pre>
  
  <p>If I in my application have an instance <code>myClass</code> of this class, step through the code in debug mode (Visual Studio 2010), and at some point types <em>myClass</em> into the Immediate Window, the following is displayed:</p>
  
  <pre><code>{MyClass}
      D: {11.11.2011 00:00:00}
      F: 3.14
      I: 42
      l: 12435
      S: "foo"
  </code></pre>
  
  <p>Getting such a string representation of the object and all its values could be very useful for logging purposes. Is there a nice and easy way to achieve this?</p>
  
  <p>I guess the Immediate Window uses reflection to loop over all fields and properties, but I thought I'd ask just in case there already exists some utility function or anything to do it.</p>