在代碼中能夠經過調用 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