【发布时间】:2012-09-28 23:57:50
【问题描述】:
在 C# 控制台应用程序中,我正在使用此代码
var ping = new Ping();
var reply = ping.Send();
if (reply.Status == IPStatus.Success)
{
Console.WriteLine("Pinging with server");
Console.WriteLine("Press any key to continue");
Console.ReadKey(true);
}
那么在var reply = ping.Send(); 中我需要传递什么参数才能写入本地机器的IP?这里我需要参数中本地机器的IP。
【问题讨论】:
-
请see the documentation first。如果 API 文档中有任何 剩余 问题未得到解答,请随时提出。另外,看这个How to: Ping a Host。
-
您可以通过以下方式获取您的本地 IP 地址:stackoverflow.com/questions/1069103/…
-
发送不“写本地机器的 ip”——通过“写 ip”我假设写到控制台......如果这不是你的意思,请澄清。跨度>
-
只要
Console.WriteLine("172.0.0.1");,你就写了你的本地IP地址...