csharp 枚举示例.s
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 枚举示例.s相关的知识,希望对你有一定的参考价值。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Enum_Example
{
class Program
{
static void Main(string[] args)
{
importance value = importance.Critical;
if (value == importance.Trivial) Console.WriteLine("Not true");
else if (value == importance.Critical) Console.WriteLine("TRUE");
Console.WriteLine("Index (of Regular): " + (int)importance.Regular + "\n\n");
//Console.WriteLine(WeekDays.Wednesday + "\n");
Console.WriteLine((int)Months.nov + "\n");
//GET KEY NAME from VALUE
Console.WriteLine(Enum.GetName(typeof(WeekDays),2));
Console.ReadKey();
}
//with enum magic constants are separeted and organised in a beautiful way
enum importance
{
None,
Trivial,
Regular,
Important,
Critical
};
private enum WeekDays
{
Sunday=1,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
};
private enum Months
{
jul = 7,
aug,
sept,
oct,
nov,
dec
};
}
}
以上是关于csharp 枚举示例.s的主要内容,如果未能解决你的问题,请参考以下文章
csharp 缓存枚举器,确保源枚举器只迭代一次
枚举的Python奇怪行为
csharp 对可枚举列表进行排序
csharp C#枚举到字符串
csharp 枚举说明
csharp 枚举到列表