Color类 通过反射将Color中定义的颜色输出

using System.Drawing;
using System.Reflection;

using System.Text;

protected void Page_Load(object sender, EventArgs e)
{
            //以Color 对象为例 输出所有定义的属性颜色
            Type t = typeof(Color);
            PropertyInfo[] properties = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
            StringBuilder sb = new StringBuilder();
            int i = 0;
            foreach (PropertyInfo info in properties)
            {
                sb.AppendFormat("<span style='background-color:{0};140px;border:2px solid #336699; margin:5px; line-height:30px; text-align:center; vertical-align:middle'>{0}</span>", info.Name);
                i++;
                //每行显示9个.
                if (i % 9 == 0)
                {
                    sb.Append("<br/>");
                }
            }
            Response.Write(sb.ToString());
}

//输出如图

没有目标的人都只在帮有目标的人完成目标

原文地址:https://www.cnblogs.com/tweet/p/1647929.html