当我返回字符串 timeTaken 时,它为空,并且它在 IDE 上这样说,尽管它已在 main 方法中定义(TimeSpan timeTaken = timer.Elapsed;)
class Program
{
public static string timeTaken;
static void Main(string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(firstline);
Stopwatch timer = new Stopwatch();
timer.Start();
using (var response = request.GetResponse());
timer.Stop();
TimeSpan timeTaken = timer.Elapsed;
...
}
}
如何输出 timeTaken?