枚举操作大全

来源:互联网 发布:win7 网络打印机脱机 编辑:程序博客网 时间:2024/06/06 01:02

定义:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace pub.Enums{    [Flags]    public enum oriention    {        north = 1,        south = 2,        east = 4,        west = 8    }}

后台代码:

oriention aa = oriention.north| oriention.east| oriention.west;            Response.Write((oriention.north | oriention.east | oriention.west)+":" +Convert.ToInt32(aa) + "<br>");            if ((int)(aa & oriention.east)!=0)            {                Response.Write(oriention.east + "包含在aa里面<br>");            }            if ((int)(aa & oriention.south) != 0)            {                Response.Write(oriention.south + "包含在aa里面<br>");            }            Response.Write("3代表:"+(oriention)3+"<br>");            Response.Write("aa & oriention.east:" + (aa & oriention.east) + "<br>");            Response.Write("aa & oriention.south:" + (aa & oriention.south) + "<br>");            Response.Write("aa & oriention.east:" + (int)(aa & oriention.east) + "<br>");            Response.Write("aa & oriention.south:" + (int)(aa & oriention.south) + "<br>");

前台输出:

north, east, west:13
east包含在aa里面
3代表:north, south
aa & oriention.east:east
aa & oriention.south:0
aa & oriention.east:4
aa & oriention.south:0






0 0
原创粉丝点击