博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第一节 33enum枚举
阅读量:4355 次
发布时间:2019-06-07

本文共 1165 字,大约阅读时间需要 3 分钟。

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();        }    }}

  

转载于:https://www.cnblogs.com/xiangxiaodong/archive/2012/02/19/2358628.html

你可能感兴趣的文章
Revit 开发将自己的窗口设置为Revit窗口
查看>>
倾斜摄影数据OSGB转换成3DML(转载)
查看>>
给年轻程序员的几句话
查看>>
ionic如何uglify和minify你的js,css,image,png....
查看>>
[LeetCode]Minimum Depth of Binary Tree
查看>>
jboss初体验
查看>>
Python列表、元组练习
查看>>
angular页面刷新
查看>>
Leetcode:7- Reverse Integer
查看>>
C6表单(方成eform)---自定义流程标题格式
查看>>
GridView下DropDownList 的选择方法onselectedindexchanged 实现方法
查看>>
Python之set集合
查看>>
Generic Repository Pattern - Entity Framework, ASP.NET MVC and Unit Testing Triangle
查看>>
Win7 下新版本Windows Virtual PC 安装SharePoint步骤详解
查看>>
SQLSERVER 升级版本的方法
查看>>
atitit.web 推送实现方案集合
查看>>
VisualSVN和VisualSVN Server有区别,前者是客户端,后者是服务器端
查看>>
jquery1.8.3 callbacks源码分析
查看>>
Mac Anaconda 安装
查看>>
Vue2.0 新手入门 — 从环境搭建到发布
查看>>