Nothing crazy here... the default behaviour of Console.WriteLine when it receives an object is to call that object's
ToString
.
An Enum's ToString returns the string representation of the enum field, which is exactly what you see.
Interestingly for you, an enum can be explicitly cast to an integer to get the value behind each field:
class MinhHoaC3
{
enum NhietDoNuoc
{
DoDong = 0,
DoNguoi = 20,
DoAm = 40,
DoNong = 60,
DoSoi = 100,
}
static void Main()
{
System.Console.WriteLine((int)NhietDoNuoc.DoDong);
System.Console.WriteLine((int)NhietDoNuoc.DoNguoi);
System.Console.WriteLine((int)NhietDoNuoc.DoAm);
System.Console.WriteLine((int)NhietDoNuoc.DoNong);
System.Console.WriteLine((int)NhietDoNuoc.DoSoi);
Console.Read();
}
}