I wrote the code :
enum FlipRotate2dEnum : byte {
NO = 0, None = 0,
R2 = 1, RotateTwice = 1,
FX = 2, FlipX = 2,
FY = 3, FlipY = 3,
D1 = 4, ReflectDiagonal1 = 4,
D2 = 5, ReflectDiagonal2 = 5,
RC = 6, RotateClockwise = 6,
RN = 7, RotateNonClockwise = 7
}
class EnumTest {
public static void Main() {
for(byte i = 0; i < 8; ++i) {
FlipRotate2dEnum v = (FlipRotate2dEnum)i;
System.Console.WriteLine("{0} {1}", i, v);
}
}
}
and I expect to see in ouput :
only short names
0 NO
1 R2
2 FX
3 FY
4 D1
5 D2
6 RC
7 RN
or only long names
0 None
1 RotateTwice
2 FlipX
3 FlipY
4 ReflectDiagonal1
5 ReflectDiagonal2
6 RotateClockwise
7 RotateNonClockwise
or names that occur first, after sorting in alphabetical order, which in this case coincides with "only short names".
But I did not expect to see what the program showed up :
0 None
1 RotateTwice
2 FlipX
3 FlipY
4 ReflectDiagonal1
5 ReflectDiagonal2
6 RotateClockwise
7 RN
Short name at the end of the output. ¿ Why ?
I tried to rearrange columns in enum :
public enum FlipRotate2dEnum : byte {
None = 0, NO = 0,
RotateTwice = 1, R2 = 1,
FlipX = 2, FX = 2,
FlipY = 3, FY = 3,
ReflectDiagonal1 = 4, D1 = 4,
ReflectDiagonal2 = 5, D2 = 5,
RotateClockwise = 6, RC = 6,
RotateNonClockwise = 7, RN = 7
}
class EnumTest {
public static void Main() {
for(byte i = 0; i < 8; ++i) {
FlipRotate2dEnum v = (FlipRotate2dEnum)i;
System.Console.WriteLine("{0} {1}", i, v);
}
}
}
and again I got a surprise in the output :
0 NO
1 R2
2 FX
3 FY
4 D1
5 D2
6 RC
7 RotateNonClockwise
¿ Why ? Please, explain to me what's going on here.
[Description]
attribute and create a method to retrieve the value contained within for a given enum value.const
offset to distinguishes between two values. likeNone = 0, NO = ConstCarrier.Offset + 0,