An explicit enumeration transformation includes the following:
From sbye,byte,short,ushort,int,uint,long,ulong,char,float,double, or decimal, to any enumeration type.
From any enumerated type to sbyte,byte,short,ushort,int,uint,long,ulong,char,float,double, or decimal.
From any enumerated type to any other enumeration type.
An explicit enumeration transformation is done in this way: it is actually an implicit or explicit conversion between the element type of an enumerated type and the corresponding type. For example, there is an enum type E with the element type int, when you perform an explicit enumeration conversion from E to Byte, you actually do an explicit numeric conversion from int to Byte, and when you perform an explicit enumeration conversion from byte to E, you are actually performing an implicit numeric conversion of byte through int.
For example, for program 6-2, we rewrite the following:
Program Listing 6-7:
Using System;
Enum weekday{
sunday,monday,tuesday,wednesday,thursday,friday,saturday
};
Class Test
{public
static void Main () {
weekday day;
Day= (weekday) 3;
Console.WriteLine (day);
}
The output of the program is:
3