[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
}
Теперь я хочу иметь возможность создать, скажем, ul в моем представлении, чтобы отображать выбранные значения моего свойства Promotion. Это то, что я сделал до сих пор, но проблема в том, как я могу получить здесь отображаемые имена?
- @foreach (int aPromotion in @Enum.GetValues(typeof(UserPromotion)))
{
var currentPromotion = (int)Model.JobSeeker.Promotion;
if ((currentPromotion & aPromotion) == aPromotion)
{ - Here I don't know how to get the display attribute of "currentPromotion".
}
}
Подробнее здесь: https://stackoverflow.com/questions/130 ... razor-code
Мобильная версия