String和enum的互相转换


String和enum的互相转换定义以下枚举

public enum BookType
{
Ticket,
Trip,
Hotel
}

从String到enum
BookType type = (BookType)Enum.Parse(typeof(BookType),"Ticket");

从enum到String
方法一:ToString();
方法二:s = Enum.GetName(typeof(BookType), BookType.Ticket);
http://blog.csdn.net/dainiao01/article/details/2454678
【String和enum的互相转换】喜欢作者简练的风格

    推荐阅读