C# 获取运行时间
//==方法定义:========== using System.Diagnostics; public delegate void Action(); public static class Run { public static double GetRunTime(Action method) { Stopwatch sw = new Stopwatch(); sw.Start(); method(); sw.Stop(); return sw.Elapsed.TotalMilliseconds; } } //==调用代码:注意用Lamp表达式========== Run.GetRunTime( ()=>{ DoSomeThing(); } ).ToString()