zoukankan      html  css  js  c++  java
  • 遍历对象属性,成员,方法的方法

    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>";
            }
        }
    }
  • 相关阅读:
    html5之缩放图标
    html5之图片的缩放scale
    html5之打地鼠100%胜率
    html5之调整旋转中心点
    html5之三角旋转
    html5中模块居中
    html5中2d图片旋转
    html5之动态移动图
    html5之steps
    读微信开放文档未解记录
  • 原文地址:https://www.cnblogs.com/JingG/p/3108503.html
Copyright © 2011-2022 走看看