gpt4 book ai didi

c# - 无法在 Razor View 中获取枚举显示名称属性

转载 作者:行者123 更新时间:2023-12-02 15:15:31 25 4
gpt4 key购买 nike

<分区>

我有一个带有 Display(Name=) 的枚举,我希望在 Razor View 中显示它,但我只获得了值。

 public enum Gender
{
[Display(Name = "Man woman")]
EveryOne = 0,
[Display(Name = "Man")]
Man = 1,
[Display(Name = "Woman")]
Woman = 2
}

Razor :

 Is for: @Model.LectureGig.Gender

Html 结果是:

Is for: Everyone

代替:

Is for: Man woman

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com