tags:

views:

220

answers:

1

Possible Duplicate:
Converting a string to an enumeration value in C#

How do I convert a enum to a string in C#?

Note: I have the answer and will post, I searched for the answer here first but couldn't find it so I thought I would add the question / answer to the site once I found it.

+1  A: 

Converting is actually quite easy. You would use the following function that is built in:

object Enum.Parse(System.Type enumType, string value, bool ignoreCase);

enum TEST_ENUM
{
  VALUE1,
  VALUE2
}

// To convert from a string to a enum just do the following
string sTestEnum = "VALUE2";

TEST_ENUM eDatabase = (TEST_ENUM)(Enum.Parse(typeof(TEST_ENUM), sTestEnum, true));
Kelsey