0
如何以字符串形式检索枚举的名称?我知道你可以得到整数值,但这不是我想要的。以字符串形式检索枚举名称
我搜索了www
,但它没有显示任何好的样本。
我做了一个示例类,以正确显示我需要的东西。
Class test
Public Property PipeEndTreatment As PipeEndTreatmentEnum
Public Enum PipeEndTreatmentEnum
SetOn
SetIn
Offset
OffsetFlush
End Enum
Private Sub TestEnumNameValue()
PipeEndTreatment = PipeEndTreatmentEnum.SetOn
Dim StringValue As String
StringValue = "SetOn" ' This value needs to be generated from the PipeEndTreatment property
End Sub
End Class
'的StringValue = PipeEndTreatment.ToString()' – Blackwood
[转换枚举为String](可能的复制http://stackoverflow.com/questions/ 483794 /转换,枚举到字符串) –