获取类中[DisplayName("")]属性的方法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Maticsoft.Common
{
public class AttributeHelper
{
public static string GetDisplayName(Type modelType, string propertyDisplayName)
{
return (System.ComponentModel.
TypeDescriptor.
GetProperties(modelType)[propertyDisplayName].
Attributes[typeof(System.ComponentModel.DisplayNameAttribute)] as System.ComponentModel.DisplayNameAttribute)
.DisplayName;
}
}
}