Enum和string的相互转换
1: public enum TFileType
2: {
3: /// <summary>
4: /// JPEG图片
5: /// </summary>
6: JPEG,
7: /// <summary>
8: /// JPG图片
9: /// </summary>
10: JPG,
11: /// <summary>
12: /// PNG图片
13: /// </summary>
14: PNG,
15: /// <summary>
16: /// GIF图片
17: /// </summary>
18: GIF
19: }
string 转 enum
(TFileType)Enum.Parse(typeof(TFileType), “JPEG”);
enum 转 string
Enum.GetName(typeof(TFileType), TFileType.PNG);