///<summary> /// equiv of PHP's var dump for an object’s properties because i cbf writing all the properties out. ///</summary> ///<param name="info"></param> private static string var_dump(object info) { StringBuilder sb = new StringBuilder();
Type t = info.GetType(); PropertyInfo[] props = t.GetProperties(); sb.AppendFormat("{0,-18} {1}", "Name", "Value"); sb.AppendLine(); foreach (PropertyInfo prop in props) { sb.AppendFormat("{0,-18} {1}", prop.Name, prop.GetValue(info, null).ToString()); sb.AppendLine(); }
return sb.ToString(); }
|
请发表评论