using System;using System.Collections.Generic;using System.Linq;using System.Text;/*枚举 *确定数量,确定值的几个取值,东西南北,男妇,上中下 * enum Gender{male,female} * enum QQStatus{online, offline, hiden} * 枚举的用法, QQStatus status = QQStatus.online * 和用字符串比下场 来,用格举的好处就是限定了变量的取值范围,程序处理起来更方便 * */namespace _33enum枚举{ enum Gender { Male,Female, Unkown}; class Program { static void Main(string[] args) { //Gender s = Gender.Male; //枚举的意义就是限定变量的取值范围 //Gender g1 = Gender.Female; Console.WriteLine("请输入你的性别:"); string sex = Console.ReadLine(); Gender s; if (sex == "男") s = Gender.Male; else if (sex == "女") s = Gender.Female; else s = Gender.Unkown; if (s == Gender.Male) { Console.WriteLine("我是男人"); } else if (s == Gender.Female) { Console.WriteLine("我是女人"); } else Console.WriteLine("保密"); Console.ReadKey(); } }}