C# 枚举实例应用是什么呢?让我们开始介绍吧:
C# 枚举实例应用之声明:
- public enum TimeOfDay
- {
- Moning = 0,
- Afternoon = 1,
- Evening = 2,
- };
C# 枚举实例应用之使用:
- public string getTimeOfDay(TimeOfDay time)
- {
- string result = string.Empty;
- switch (time)
- {
- case TimeOfDay.Moning:
- result = "上午";
- break;
- case TimeOfDay.Afternoon:
- result = "下午";
- break;
- case TimeOfDay.Evening:
- result = "晚上";
- break;
- default:
- result = "未知";
- break;
- }
- return result;
- }
C# 枚举实例应用的基本内容就向你介绍到这里,希望对你了解和学习C# 枚举有所帮助。
【编辑推荐】