gpt4 book ai didi

.net - 如何从 VB.NET 中的枚举中获取描述?

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

<分区>

我有如下枚举

Public Enum FailureMessages
<Description("Failed by bending")>
FailedCode1 = 0

<Description("Failed by shear force")>
FailedCode2 = 1
End Enum

每个枚举都有自己的描述。例如,FailedCode1 有其自己的描述“弯曲失败”。

下面是我的主要 Sub(),我想在其中为相应的枚举分配一个变量(字符串类型)。

 Sub Main()
Dim a As Integer = FailureMessages.FailedCode1
Dim b As String 'I would b = Conresponding description of variable a above
'that means: I would b will be "Failed by bending". How could I do that in .NET ?
End Sub

任何人都可以帮助我,我怎么能在 VB.NET 中做到这一点

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