我有以下代码
public class Test
{
public static long Method1(Action a)
{
var s = Stopwatch.StartNew();
a.Invoke();
s.Stop();
return s.Elapsed.TotalMilliseconds;
}
}
在另一堂课上我怎么称呼它
double elapsed = 0;
for (int i = 0; i < 100000; i++)
{
elapsed+= (TestHelper.Timer(() => session.SaveTransaction(transaction)));
}
Debug.WriteLine(string.Format("avg execution time is {0} ms", elapsed/100000));
哪个不编译。呼叫代码应该如何?