能不能用字典表+委托替代switch?
class Program{ delegate string Func(); static void Main(string[] args) { var Dict = new System.Collections.Generic.Dictionary<string, Func>(); Dict["Apple"] = new Func(Apple); Dict["Google"] = new Func(Google); Dict["IBM"] = new Func(IBM); string cmd; while ("exit" != (cmd = System.Console.ReadLine())) { if (Dict.ContainsKey(cmd)) System.Console.WriteLine(Dict[cmd]()); } } static string Apple() { return "Apple()"; } static string Google() { return "Google()"; } static string IBM() { return "IBM()"; }}