How can I parse a string in VB.NET to enum value?
Example I have this enum:
Public Enum Gender
NotDefined
Male
Female
End Enum
how can I convert a string "Male" to the Gender enum's Male value?
How can I parse a string in VB.NET to enum value?
Example I have this enum:
Public Enum Gender
NotDefined
Male
Female
End Enum
how can I convert a string "Male" to the Gender enum's Male value?
If you want the parse to be case insensitive, you can use the following:
[Enum].Parse(Gender, DirectCast(MyGender, String), True)
This will handle dim MyGender as string = "Male" or dim MyGender as string = "male"