C#枚舉類(lèi)型實(shí)例演示
作者:gisland 
  C#枚舉類(lèi)型實(shí)例演示中向你展示了C#枚舉類(lèi)型的具體使用,希望對(duì)你學(xué)習(xí)和了解C#枚舉類(lèi)型有所幫助。
 C#枚舉類(lèi)型實(shí)例演示
- /*
 - * Created by SharpDevelop.
 - * User: noo
 - * Date: 2009-8-16
 - * Time: 21:03
 - *
 - * C#枚舉類(lèi)型
 - */
 - using System ;
 - enum enumA:int
 - {
 - east,//0
 - south,//1
 - west,//2
 - north,//3
 - }
 - enum enumB//默認(rèn)是int型的
 - {
 - left,//0
 - right,//1
 - }
 - enum enumC:byte
 - {
 - top,
 - buttom,
 - } //C#枚舉類(lèi)型
 - class Test
 - {
 - static void Main()
 - {
 - enumA a=enumA.east;
 - enumA b=enumA.south;
 - enumA c=enumA.west;
 - enumA d=enumA.north;
 - Console.WriteLine (a);
 - Console.WriteLine (b);
 - Console.WriteLine (c);
 - Console.WriteLine (d);
 - int aa=(int)enumA.east;
 - int bb=(int)enumA.south;
 - int cc=(int)enumA.west;
 - int dd=(int)enumA.north;
 - Console.WriteLine (aa);
 - Console.WriteLine (bb);
 - Console.WriteLine (cc);
 - Console.WriteLine (dd);
 - enumB x=enumB.left ;
 - enumB y=enumB.right ;
 - int z=(int)enumB.left;
 - Console.WriteLine (x);
 - Console.WriteLine (y);
 - Console.WriteLine (z);
 - //C#枚舉類(lèi)型
 - enumC p=enumC.top ;
 - enumC q=enumC.buttom ;
 - byte r=(byte)enumC.buttom ;
 - Console.WriteLine (p);
 - Console.WriteLine (q);
 - Console.WriteLine (r);
 - }
 - }
 
C#枚舉類(lèi)型實(shí)例運(yùn)行結(jié)果

C#枚舉類(lèi)型實(shí)例演示的基本情況就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C#枚舉類(lèi)型有所幫助。
【編輯推薦】
責(zé)任編輯:仲衡 
                    來(lái)源:
                    博客園
 














 
 
 
 
 
 
 