StringBuilder sb = new StringBuilder(); //sb.Append(WebAPI.HelloWorld() + "<br>"); //WebAPI任意实例化的对象 Type t = WebAPI.GetType(); PropertyInfo[] propertys = t.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo pi in propertys) { try { sb.Append(pi.Name + "(" + pi.PropertyType.Name + "):" + pi.GetValue(WebAPI, null).ToString() + "<br>"); } catch { sb.Append(pi.Name + "(" + pi.PropertyType.Name + "):-<br>"); } } //sb.Append(WebAPI.Url + "<br>"); //sb.Append(WebAPI.UserAgent + "<br>"); //sb.Append(WebAPI.RequestEncoding + "<br>"); //sb.Append(WebAPI.HelloWorld()+"<br>"); Response.Write(sb.ToString());