Jacob said:
All enum values should equal an integer value, so you can just cast it
as an integer.
Hello,
After much reading and much googling I came up with this:
Get names and indexes of enum:
For Each color As Color In [Enum].GetValues(GetType(Color))
Dim name As String = MyF(color, Thread.CurrentThread.CurrentCulture)
Dim index As Integer = CType(color, Integer)
Response.Write("Name: " & name & " | Index: " & index.ToString & "<br
/>")
Next
MyF is a function which returns a string for a giving culture and enum
name:
Public Function MyF(ByVal color As Color, ByVal culture As CultureInfo)
As String
....
Get one enum name from its index:
Dim s As String = "20"
Dim i As Integer = CType(s, Integer)
If Color.IsDefined(GetType(Color), i) Then
Dim name As Color = CType(i, Color)
Response.Write(name.ToString)
End If
Need second opinion. What do you think?
I am asking this because my Response.Write seems to show the right
results but further on in my code I am having some problems and I am
not sure if it comes from here and until now I wasn't able to figure
this out.
Thanks,
Miguel