字符串和枚举相互转换
定义一个枚举: private enum myType { a = 1, b = 2, c = 3, lao = 4 } //字符串转枚举 bool TryParse = Enum.IsDefined(typeof(myType), "a"); if (TryParse) { object m = Enum.Parse(typeof(myType), "c"); myType t = (myType)m; }
//枚举转字符串 myType.a.ToString();