我的模型中有一个名为"Promotion"的属性,它的类型是一个名为"UserPromotion"的标志枚举.我的枚举成员的显示属性设置如下:
[Flags]
public enum UserPromotion
{
None = 0x0,
[Display(Name = "Send Job Offers By Mail")]
SendJobOffersByMail = 0x1,
[Display(Name = "Send Job Offers By Sms")]
SendJobOffersBySms = 0x2,
[Display(Name = "Send Other Stuff By Sms")]
SendPromotionalBySms = 0x4,
[Display(Name = "Send Other Stuff By Mail")]
SendPromotionalByMail = 0x8
}
Run Code Online (Sandbox Code Playgroud)
现在我希望能够在我的视图中创建一个ul来显示我的"Promotion"属性的选定值.这是我到目前为止所做的,但问题是如何在这里获取显示名称?
<ul>
@foreach (int aPromotion in @Enum.GetValues(typeof(UserPromotion)))
{
var currentPromotion = (int)Model.JobSeeker.Promotion;
if ((currentPromotion & aPromotion) == aPromotion)
{
<li>Here I don't know how to get the display attribute of …Run Code Online (Sandbox Code Playgroud)