2009-06-23 52 views

回答

1

轉換其實很簡單。你可以使用內置於以下功能:

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));