在这里完成 nube。刚学:)
我做了一些研究,但无法得到答案。
我正在尝试在文本框中显示我的网关 IP。这是我的代码(从片段构建):
foreach (NetworkInterface f in NetworkInterface.GetAllNetworkInterfaces())
if (f.OperationalStatus == OperationalStatus.Up)
foreach (GatewayIPAddressInformation d in f.GetIPProperties().GatewayAddresses)
Gateway_Address.Text = d.Address.ToString();
文本框只显示“::”
现在,如果我使用(从另一个线程复制):
foreach (NetworkInterface f in NetworkInterface.GetAllNetworkInterfaces())
if (f.OperationalStatus == OperationalStatus.Up)
foreach (GatewayIPAddressInformation d in f.GetIPProperties().GatewayAddresses)
MessageBox.Show(d.Address.ToString());
消息框显示 IP。为什么输出不同?