如何遍历枚举的所有值?
using System;
namespace PSP
{
class GetEnumValues
{
public static void Main()
{
Type Sexs = typeof(SexKind);
Console.WriteLine("The kinds of the Sex:");
foreach (string s in Enum.GetNames(Sexs))
{
Console.WriteLine(s);
}
}
}
enum SexKind
{
Male,
Female
}
}
namespace PSP
{
class GetEnumValues
{
public static void Main()
{
Type Sexs = typeof(SexKind);
Console.WriteLine("The kinds of the Sex:");
foreach (string s in Enum.GetNames(Sexs))
{
Console.WriteLine(s);
}
}
}
enum SexKind
{
Male,
Female
}
}