110,539
社区成员
发帖
与我相关
我的任务
分享
public enum TYPE
{
Healer,Rogue,Worrier
}
// [StringLength(10)]
public TYPE Type { get; set; }
public enum EnumType
{
Healer, Rogue, Worrier
}
//[StringLength(10)]
public string strEnum { get; set; }
//获取枚举值用这个属性
public EnumType MyEnumType
{
get
{
Type tEnum = typeof(EnumType);
object objEnum = Enum.Parse(tEnum, strEnum, true);
EnumType rtype = default(EnumType);
rtype = (EnumType)objEnum;
return rtype;
}
}
修改一下
public enum EnumType
{
Healer, Rogue, Worrier
}
//[StringLength(10)]
public string strEnum { get; set; }
//获取枚举值用这个属性
public EnumType MyEnumType
{
get
{
Type tEnum = typeof(EnumType);
object objEnum = Enum.Parse(tEnum, strEnum, true);
EnumType rtype = default(EnumType);
rtype = objEnum as EnumType;
return rtype;
}
}
字符串大概也可以这样整吧!