GPPointFileInfo\ObjectToString.cs
Creating a non-trival custom GP tool - inputs, outputs, and responding to environment settings
GPPointFileInfo\ObjectToString.cs
// Copyright 2008 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See use restrictions at <your ArcGIS install location>/developerkit/userestrictions.txt.
// 

using System.Reflection;
using System;
using System.Diagnostics;

namespace GPPointFileInfo
{
    public static class ObjectToString
    {
        public static string GetToString(object o)
        {
            string toString = o.ToString() + "\n";

            PropertyInfo[] propertyInfoArray = o.GetType().GetProperties();

            foreach (PropertyInfo propertyInfo in propertyInfoArray)
            {
                try
                {
                    toString += propertyInfo.Name + " = " + propertyInfo.GetValue(o, null) + "\n";
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                }
            }

            toString += "\n";

            return toString;
        }

        public static string GetNewline()
        {
            const string Newline = "\n";

            return Newline + Newline;
        }
    }
}