语法: enum 类型名 { 限定的值 };
枚举的意义就在于限定变量的取值范围
例如:
namespace 枚举
{
enum Gender {male,female,Unknown };
class Program
{
static void Main(string[] args)
{
Gender s = Gender.male;
Console.ReadKey();
}
}
}
枚举的意义就在于限定变量的取值范围
例如:
namespace 枚举
{
enum Gender {male,female,Unknown };
class Program
{
static void Main(string[] args)
{
Gender s = Gender.male;
Console.ReadKey();
}
}
}