标签:style blog color io os ar sp div on
enum<typeName> { <value1>, <value2>, <value3>, <value4>, ... <valueN>, }
举例:
namespace ConsoleApplication1 { enum orientation : byte { north=1, south=2, east=3, west=4, } class Program { static void Main(string[] args) { byte directionByte; string directionString; orientation myDirection = orientation.north; Console.WriteLine("myDirection={0}",myDirection); directionByte = (byte)myDirection; directionString = Convert.ToString(myDirection); Console.WriteLine("byte equivalent={0}",directionByte); Console.WriteLine("string equivalent={0}", directionString); Console.ReadKey(); } } }
标签:style blog color io os ar sp div on
原文地址:http://www.cnblogs.com/haizhibin1989/p/4051346.html