Chris Canal

A Scottish .NET Developer

  Home  |   Contact  |   Syndication    |   Login
  23 Posts | 0 Stories | 34 Comments | 0 Trackbacks

News

Twitter












Archives

Post Categories

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?
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Monday, January 07, 2008 3:48 AM