enum or : byte { north = 1, south = 2, east = 3, west = 4 } class Program { static void Main(string[] args) { or myd = or.north; Console.WriteLine("myd={0}", myd); Console.WriteLine($"myd={myd}"); Console.WriteLine("(byte)myd="+(byte)myd); Console.WriteLine("Convert.ToString(myd)=" + Convert.ToString(myd)); Console.WriteLine("Convert.ToByte(myd)="+Convert.ToByte(myd)); Console.ReadKey(); } } //顯示 myd=north myd=north (byte)myd=1 Convert.ToString(myd)=north Convert.ToByte(myd)=1 |
|
來自: 工廠應(yīng)用 > 《C#》