C#1114 枚举










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,cint 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;////所有类型后都可加?表示可空类型描述 nulldecimal? count1 = null;decimal count2 = 12;//枚举aenumt 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));}}
}