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

        }
    }
}
相关推荐
hixiong12311 分钟前
TensorRT转换工具分享
人工智能·计算机视觉·ai·c#
cui_ruicheng19 分钟前
Python从入门到实战(六):非序列容器
开发语言·python
西西学代码26 分钟前
Flutter---底部导航栏(2)
开发语言·javascript·flutter
legendary_16327 分钟前
SINK芯片:Type-C统一供电时代的小家电核心方案
c语言·开发语言·人工智能·智能手机
momo29 分钟前
JAVA基础知识
java·开发语言
凯瑟琳.奥古斯特1 小时前
力扣1013三等分解法与C++实现
开发语言·c++·算法·leetcode·职场和发展
xxie1237942 小时前
Python装饰器与语法糖
开发语言·python
莫生灬灬2 小时前
DY联系人聊天Web面板支持获取联系人/聊天记录/发送消息
前端·chrome·websocket·c#
郑州光合科技余经理2 小时前
海外外卖平台源码改造实战——多语言核心代码实现
java·开发语言·前端·后端·mysql·架构·php
凯瑟琳.奥古斯特2 小时前
力扣1012数位DP解法详解
开发语言·c++·算法·leetcode·职场和发展