首页 > 代码库 > .net: FlagsAttribute 特性

.net: FlagsAttribute 特性

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace mqnh{    class flagdemo    {        public void flagtest() {            for (int i = 0; i < 16; i++)            {                Console.WriteLine("{0}-{1}", i, (flagsdemo)i);            }            for (int i = 0; i < 16; i++)            {                Console.WriteLine("{0}-{1}", i, (single)i);            }            flagsdemo d = (short)flagsdemo.five + flagsdemo.three;            Console.WriteLine(d);        }    }    [Flags]    enum flagsdemo : short    {        one=0,        tow=1,        three=2,        four=4,        five=8    }    enum single : short    {        one = 0,        tow = 1,        three = 2,        four = 4,        five = 8    }}

 

.net: FlagsAttribute 特性