这是测量代码耗时的最简单方法 12345678static void Time(Action method){ var sw = new Stopwatch(); sw.Start(); method(); sw.Stop(); Console.WriteLine("耗时:{0}", sw.Elapsed);}