(:source lang=C# :)

using System.Reflection;

...

        public override string ToString() {
            StringBuilder sb = new StringBuilder();

            sb.Append(this.GetType().ToString() + ": {");
            sb.Append("Foo: {");
            foreach (PropertyInfo p in this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
                sb.Append(p.Name + ": " + p.GetValue(this, null) + "; ");
            }
            sb.Append("}");
            return sb.ToString();
        }