对枚举变量设置了不同的int数值的时候,实际上对应枚举变量的索引顺序发生了改变
普通枚举变量
...
int i=0;
foreach (actionStr step in Enum.GetValues(typeof(test_enum)))
{
Debug.Log(" i:" + i + " step:" + step.ToString()+ "///(int)step:" + (int)step);
i++;
}//
...
...
[System.Serializable]
public enum test_enum
{
aa,
bb,
cc,
dd,
ee,
}//
显示结果:
i:0 step:aa///(int)step:0
i:1 step:bb///(int)step:1
i:2 step:cc///(int)step:2
i:3 step:dd///(int)step:3
i:4 step:ee///(int)step:4
...
int i=0;
foreach (actionStr step in Enum.GetValues(typeof(test_enum)))
{
Debug.Log(" i:" + i + " step:" + step.ToString()+ "///(int)step:" +