日期:2014-05-18 浏览次数:21137 次
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()"; } }