lundi 1 juin 2015

c# Naming an enum from a string [duplicate]

This question already has an answer here:

So I have a list of strings read from an XML file and was wondering if I can create a list of enums from the strings.

For example and clarity on the question:

String list in an array already read in from XML file:

    "aString"
    "bString"
    "cString"

Is there a way to convert those strings into:

enum eAnEnumType
{
      aString = 0,
      bString,
      cString
}

This is so I am able to use them as named flags read in from an XML. I had done some research around this subject and reflection seems to come up alot, but I have not used c# in a while, and never used reflection...

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire