Given:
public enum myType
{
Val1 = 1,
Val2 = 2,
Val3 = 3
}
开发者_如何学JAVAand code elsewhere in the app where a value : ... row.myType // resolves to Val1 ...
I need to translate row.myType to 1
Simply cast to an int:
int enumValue = (int)row.MyTime;
cast it to int
(int)row.myTime
You can simply cast it to an integer:
(int)row.myType;
myType someEnumVal = myType.Val1;
int intValOfEnum = (int)someEnumVal;
精彩评论