本文介绍了枚举疯狂???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class MinhHoaC3
{
enum NhietDoNuoc
{
DoDong = 0,
DoNguoi = 20,
DoAm = 40,
DoNong = 60,
DoSoi = 100,
}
static void Main()
{
System.Console.WriteLine(NhietDoNuoc.DoDong);
System.Console.WriteLine(NhietDoNuoc.DoNguoi);
System.Console.WriteLine(NhietDoNuoc.DoAm);
System.Console.WriteLine(NhietDoNuoc.DoNong);
System.Console.WriteLine(NhietDoNuoc.DoSoi);
Console.Read();
}
}




出:



X | X | X | X |
不要出门:

0
20
40
60
100

:confused :: confused :: confused:




Out:



X| X| X| X|
Don`t out:

0
20
40
60
100

:confused::confused::confused:

推荐答案

System.Console.WriteLine(NhietDoNuoc.DoDong);
System.Console.WriteLine(NhietDoNuoc.DoNguoi);
System.Console.WriteLine(NhietDoNuoc.DoAm);
System.Console.WriteLine(NhietDoNuoc.DoNong);
System.Console.WriteLine(NhietDoNuoc.DoSoi);


方法toString()(请参阅[ ^ ])被隐式调用(顺便说一下,这是C# enum s的一个非常有用的功能).
请参见(再次提供文档)[ ^ ]正确使用enum s.

:)


the method toString() (see [^]) is implicitely called (incidentally this is a very useful feature of C# enums).
See (documentation, again) [^] for proper usage of enums.

:)


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();
}
}


这篇关于枚举疯狂???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 00:04