C#1114 枚举










csharp 复制代码
namespace Variable
{//bool 布尔值 true /false 默认false
    //byte 8位无符号整数 0-255 默认0
    //char 字符          U+0000 U+ffff       "\0"
    //decimal 128位精确十进制     0.0M
    //double 64位双精度浮点 小数一般都用
    //float 32单精度 小数一般都用
    //int 32位有符号整数 一般都用
    //long 64位有符号整数类型
    //sbyte 8位有符号整数 -128-127
    //short 16位有符号整数 
    //
    enum numType
    {
        学生,
           师,
           OK

        //作用域影响
    }
    internal class Program

    {enum enumt
        {
            OK=1,
                LO=2

        }

        //int a,b,c
        int a;
        int b;
        int c;
        int d;
        int JJ阿斯顿;
        int l = 1;
        int 撒旦 = 2;
        int s = 3;
        void Set()
        {
           s = 100;
        }
        static void Main(string[] args)
        {
            string input = "";
     //       Console.Write("input=:");
            input = Console.ReadLine();
      //      Console.WriteLine("Hello, World!");
       //     Console.WriteLine("变量Input=" + input);
            //整型
      //      sbyte a2= -200;//-128-+127 超出范围
        //    short num1 = 234000;//短整型 -32768-+32767
          //  int count = 23456;
           // int size = sizeof(int);//获取类型字节数
            //浮点型
            //float double decimal
           // float f1 = 4.5;
            float f2 = 4.5f;
            double f3 = 4.5;
            decimal d3 = 4.5M;
            bool b1= true;
            //bool值
            int count = 3;
            bool blAdd = (count > 0);//ture
            //字符型 char
          //  char c = '\r\n';
           // ushort intC = c;//65
                            // \n换行

            Nullable<int> value=null;

            int? value1 = null;//
            //所有类型后都可加?表示可空类型描述 null
            decimal? count1 = null;
            decimal count2 = 12;

            //枚举a
            enumt emumt2 = enumt.OK;
            //获取枚举变量的值
            int val = (int)emumt2;
            //
               int o = 1;
            //获取枚举名称
            string oname = Enum.GetName(typeof(enumt),o);
            //根据值获取枚举对象
            enumt otype= (enumt)Enum.Parse(typeof(enumt), o.ToString());
            //根据枚举名称获取枚举对象
            enumt otype2 = (enumt)Enum.Parse(typeof(enumt), oname);
            //获取枚举名称数组
            string[] names = Enum.GetNames(typeof(enumt));
            //获取枚举值数组
            var values = Enum.GetValues(typeof(enumt));

        }
    }
}
相关推荐
Ray Liang3 小时前
用六边形架构与整洁架构对比是伪命题?
java·python·c#·架构设计
Scout-leaf3 天前
WPF新手村教程(三)—— 路由事件
c#·wpf
用户298698530143 天前
程序员效率工具:Spire.Doc如何助你一键搞定Word表格排版
后端·c#·.net
mudtools4 天前
搭建一套.net下能落地的飞书考勤系统
后端·c#·.net
玩泥巴的5 天前
搭建一套.net下能落地的飞书考勤系统
c#·.net·二次开发·飞书
唐宋元明清21885 天前
.NET 本地Db数据库-技术方案选型
windows·c#
郑州光合科技余经理5 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
lindexi5 天前
dotnet DirectX 通过可等待交换链降低输入渲染延迟
c#·directx·d2d·direct2d·vortice
feifeigo1235 天前
matlab画图工具
开发语言·matlab
dustcell.5 天前
haproxy七层代理
java·开发语言·前端