gpt4 book ai didi

C#枚举如何检查枚举中是否存在描述

转载 作者:行者123 更新时间:2023-12-02 22:09:23 27 4
gpt4 key购买 nike

<分区>

我想知道是否有一种方法可以检查该值是否是枚举的描述。我知道

     Enum.IsDefined(typeof(EnumEntity),value)

可用于检查值是否在枚举中,但描述如何?

例如,

 public enum LicenseTypes 
{
[Description("A License")]
A,
[Description("B License")]
B,
[Description("C License")]
C
}

有没有办法检查“A License”是对枚举 LicenseTypes 的描述?

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