JingG

 

using System;
using System.Reflection;
using System.Web;

namespace WebApplication5
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpRuntime hr = new HttpRuntime();
            DisplayValues(hr);
        }
        public void DisplayValues(object o)
        {
            Type type = o.GetType();
            outPut("<hr>Methods<br>");
            MethodInfo[] methodInfos = type.GetMethods();
            foreach (MethodInfo m in methodInfos)
            {
                outPut(m.Name);           
            }

            outPut("<hr>Fields<br>");
            FieldInfo[] fieldInfos = type.GetFields();
            foreach (FieldInfo f in fieldInfos)
            {
                outPut(f.Name + ": " + f.GetValue(null).ToString());
            }

            outPut("<hr>Properties<br>");
            PropertyInfo[] propertyInfos = type.GetProperties();
            foreach (PropertyInfo p in propertyInfos)
            {
                outPut(p.Name + ": " + p.GetValue(null, null).ToString());
            }
        }
        public void outPut(string s)
        {
            ltl1.Text += s + "<br>";
        }
    }
}

 

分类:

技术点:

相关文章:

  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
相关资源
相似解决方案