Geeks With Blogs
Chris Canal A Scottish .NET Developer
I've being considering using reflection within a classes .ToString() method, something along the lines of this:

    public override string ToString()
            StringBuilder toString = new StringBuilder();
            PropertyInfo[] props = GetType().GetProperties();

            foreach (PropertyInfo prop in props)
                toString.AppendFormat("{0} : {1} || ", prop.Name, prop.GetValue(this, null));

            return toString.ToString();

Is this smelly code? Posted on Monday, January 7, 2008 3:48 AM development | Back to top

Copyright © Chris Canal | Powered by: