标签:转换 msdn image ons 字符串 图片 style 整型 ram
1 enum 枚举名 2 { 3 枚举成员 [=常数表达式] 4 ...... 5 }
1 enum Color 2 { 3 Red, 4 Yellow, 5 Green 6 } 7 class TrafficLight 8 { 9 public static void WhatInfo(Color color) 10 { 11 switch(color) 12 { 13 case Color.Red: 14 Console.WriteLine("Stop!"); 15 break; 16 case Color.Yellow: 17 Console.WriteLine("Warning!"); 18 break; 19 case Color.Green: 20 Console.WriteLine("Go!"); 21 break; 22 default: 23 break; 24 } 25 } 26 } 27 class Program 28 { 29 static void Main(string[] args) 30 { 31 Color c = Color.Red; 32 Console.WriteLine(c.ToString()); 33 TrafficLight.WhatInfo(c); 34 c = (Color)Enum.Parse(typeof(Color), "Green"); 35 Console.WriteLine(c.ToString()); 36 TrafficLight.WhatInfo(c); 37 Console.ReadKey(); 38 } 39 }
标签:转换 msdn image ons 字符串 图片 style 整型 ram
原文地址:https://www.cnblogs.com/fanjianzhi/p/12820116.html