using System.Net; using System.Net.NetworkInformation; namespace xumh { class MyApp { public static void Main() { PingReply reply = new Ping().Send("127.0.0.1"); if(reply.Status == IPStatus.Success) System.Console.WriteLine("Ping successfully."); else System.Console.WriteLine("Ping failure."); } };} 转载于:https://www.cnblogs.com/flaaash/archive/2008/03/03/1088850.html