How to get the Display Name Attribute of an Enum member via MVC razor code?

后端 未结 20 2381
孤街浪徒
孤街浪徒 2020-11-22 09:30

I\'ve got a property in my model called \"Promotion\" that its type is a flag enum called \"UserPromotion\". Members of my enum have display attributes set as follows:

20条回答
  •  清酒与你
    2020-11-22 09:54

    Based on Aydin's answer I would suggest a less "duplicatious" implementation (because we could easily get the Type from the Enum value itself, instead of providing it as a parameter

提交回复
热议问题