反射获得DescriptionAttribute的方法
2015-03-28 10:27:49 访问(1967) 赞(0) 踩(0)
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace SlowX.WebOperApp.Classes.Classes
{
[Serializable]
public class ConfigInfo
{
public ConfigInfo()
{
}
/// <summary>
/// FillChar
/// </summary>
[CategoryAttribute("属性"), DescriptionAttribute("填充模式")]
public string TheName
{
get
{
return "canoe";
}
}
/// <summary>
/// FillChar
/// </summary>
[CategoryAttribute("属性"), DescriptionAttribute("填充模式")]
public string Go()
{
return "canoe1";
}
}
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
ConfigInfo uc = new ConfigInfo();
Type t = uc.GetType();
//PropertyInfo pInfo = t.GetProperty("TheName");
//MessageBox.Show(pInfo.Name);
MethodInfo theInfo = t.GetMethod("Go");
MessageBox.Show(theInfo.Name);
}
标签:
反射获得DescriptionAttribute的方法 


上一条:
下一条:
相关评论
发表评论