Assign int value to the custom enum property
This question already has an answer here:
Just cast the int
to the enum
.
o.MyEnum = (CustomEnumProp) myInt;
You can also use the Enum.IsDefined
method to check that the int
is valid.
if (Enum.IsDefined(typeof(CustomEnumProp), myInt))
o.MyEnum = (CustomEnumProp) myInt;
链接地址: http://www.djcxy.com/p/22522.html
下一篇: 将int值分配给自定义枚举属性