111,126
社区成员
发帖
与我相关
我的任务
分享
PropertyInfo info;//循环取得的属性
object[] objs = info.GetCustomAttributes(typeof(ColumNameAttribute), false);
class Program
{
static void Main(string[] args)
{
Student st = new Student();
Type t = st.GetType();
foreach (var item in t.GetProperties())
{
object[] objs = item.GetCustomAttributes(typeof(ColumNameAttribute), false);
if (objs.Length > 0)
{
Console.WriteLine(string.Format("{0} cusName:{1}", item.Name, (objs[0] as ColumNameAttribute).ColumName));
}
}
Console.ReadKey();
}
}