在代码中能够经过调用 System.Net.NetworkInformation 命名控件下的 Ping 类的 Send() 方法来实现,代码以下:web
var ping = new System.Net.NetworkInformation.Ping(); var result = ping.Send("www.google.com"); if (result.Status != System.Net.NetworkInformation.IPStatus.Success) return;
返回的结果是 PingReply 类型,定义以下:google
上述代码中的 result 结果以下:spa
参考:code