How do I .. use Reflection to get the values of an Enum at runtime
26-Mar-1212 Leave a comment
Thanks to:
http://www.vb-helper.com/howto_net_list_enum.html
Module Module1
Sub Main()
ForEach field As System.Reflection.FieldInfoInGetType(TestEnum).GetFields.Where(Function(f) f.IsLiteral)
‘Console.WriteLine(field.Name + vbTab + CInt(field.GetValue(Nothing)).ToString)
Console.WriteLine(CInt(field.GetValue(Nothing)).ToString + ” “ + field.Name)
Next
Console.ReadLine()
End Sub
End Module
Public Enum TestEnum
Cheese = 1
Wallace
Grommit
Wheelbarrows
End Enum