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 /轉換,枚舉到字符串) –