小编Bla*_*tar的帖子

在c#中使用ping

当我使用Windows Ping远程系统时,它说没有回复,但是当我用c#ping时,它表示成功.Windows正确,设备未连接.为什么我的代码能够在Windows不成功时成功ping?

这是我的代码:

Ping p1 = new Ping();
PingReply PR = p1.Send("192.168.2.18");
// check when the ping is not success
while (!PR.Status.ToString().Equals("Success"))
{
    Console.WriteLine(PR.Status.ToString());
    PR = p1.Send("192.168.2.18");
}
// check after the ping is n success
while (PR.Status.ToString().Equals("Success"))
{
    Console.WriteLine(PR.Status.ToString());
    PR = p1.Send("192.168.2.18");
}
Run Code Online (Sandbox Code Playgroud)

c# ping

83
推荐指数
2
解决办法
17万
查看次数

标签 统计

c# ×1

ping ×1