using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace c编程练习题 { public enum QQState { OnLine=1 , // 枚举类型默认初始值为0,赋给1值才能符合控制台输出结果。 OffLine , Leave , Busy , QMe, } class Program { static void Main(string[] args) { //提示用户选择一个在线状态,我们接收,并将用户的输入转化成枚举类型。 //再次打印到控制台中。 Console.WriteLine("请输入您的QQ在线状态(1--Online,2--Offline 3--Leave 4--Busy 5--QMe)"); string input = Console.ReadLine(); switch (input) { case "1": QQState s1 = (QQState)Enum.Parse(typeof(QQState), input); Console.WriteLine("您选择的在线状态是{0}", s1); break; case "2": QQState s2 = (QQState)Enum.Parse(typeof(QQState), input); Console.WriteLine("您选择的在线状态是{0}", s2); break; case "3": QQState s3 = (QQState)Enum.Parse(typeof(QQState), input); Console.WriteLine("您选择的在线状态是{0}", s3); break; case "4": QQState s4 = (QQState)Enum.Parse(typeof(QQState), input); Console.WriteLine("您选择的在线状态是{0}", s4); break; case "5": QQState s5 = (QQState)Enum.Parse(typeof(QQState), input); Console.WriteLine("您选择的在线状态是{0}", s5); break; } Console.ReadLine(); } } }