Possible Duplicate:
Why enums require an explicit cast to int type?
I defined this enumeration:
public enum GroupTypes : int
{
gt_table0 = 0
gt_table1 = gt_table0 + 1,
gt_table2 = gt_table1 + 1,
gt_table3 = gt_table2 + 1,
gt_table4 = gt_table3 + 1,
gt_table5 = gt_table4 + 1,
gt_table6 = gt_table5 + 1,
gt_table7 = gt_table6 + 1,
gt_table8 = gt_table7 + 1
}
I then use this enum as follows:
for (int i = 0; i < NbrTables; i++)
{
// Compute starting table
int StartGroup = GroupTypes.gt_table0 + i;
// Some more code here
}
Where I am confused is when I use the enumeration to compute my StartGroup, I get the error "Cannot implicitly convert type 'GroupTypes' to 'int'. An explicit conversion exists'.
I thought that I would avoid this error since I declared the GroupTypes enum as an int.
Where is my mis-understanding?