我需要确定是否发生超时并将条目保存到列表数组中。
这就是我 ping 并将往返值添加到一个列表数组的方式:
static void Ping()
{
Console.Write(Environment.NewLine + "Start the test? (y/n): ");
if (Console.ReadLine().ToLower() == "y")
{
List<int> lag = new List<int>();
Console.WriteLine();
for (int server = 1; server <= 139; server++)
{
string url = "world" + server.ToString() + ".runescape.com";
Console.WriteLine("Checking world " + server + "...");
Ping ping = new Ping();
PingReply reply = ping.Send(url);
lag.Add(int.Parse(reply.RoundtripTime.ToString()));
}
// ... More Code Here ...
}
}
这该怎么做?