[RESOLVED] Getting Enum value based on string
I'm still searching, but there's a crap load of posts with "enum" and "value" in it... so I'm posting this as a short cut while I still attempt to search.
Short description: I have a file that will have a field where the value will be "string" or "date" or "number" ... I need to translate these into an enum type:
Company.NameSpace.Assembly.DataTypes.String
Company.NameSpace.Assembly.DataTypes.Date
Company.NameSpace.Assembly.DataTypes.Number
Company.NameSpace.Assembly.DataTypes.Boolean
and so on... so that I can pass it to another method that's expecting the enumeration value as a parameter.
I know there's a way to go from the value to get to the "text" of the enum... is there a way to go the other way?
-tg
Re: Getting Enum value based on string
Apparently I just needed to be a little more patient...
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
-tg
Re: [RESOLVED] Getting Enum value based on string
try this
Code:
Dim myEnum as Company.NameSpace.Assembly.DataTypes = DirectCast([Enum].Parse(GetType(Company.NameSpace.Assembly.DataTypes), "String"), Company.NameSpace.Assembly.DataTypes)
Re: [RESOLVED] Getting Enum value based on string
Indeed! That's basically what I ended up with... Stupid thing is that this isn't the first time I've done this... snaaaarf!
It also turns out that we're treating everything like a string when we first import it, so I didn't even need to worry about the type.... grumble grumble grumble...
-tg