您好,欢迎访问一九零五行业门户网

如何使用C#显示机器的IP地址?

使用 iphostentry.addresslist 属性获取 ip 地址 -
iphostentry myip = dns.gethostentry(hostname);ipaddress[] address = myip.addresslist;
尝试以下代码来显示 ip 地址 -
示例using system;using system.net;class program { static void main() { string hostname = string.empty; hostname = dns.gethostname(); console.writeline("hostname: "+hostname); iphostentry myip = dns.gethostentry(hostname); ipaddress[] address = myip.addresslist; for (int i = 0; i < address.length; i++) { console.writeline("ip address {1} : ",address[i].tostring()); } console.readline(); }}
以上就是如何使用c#显示机器的ip地址?的详细内容。
其它类似信息

推荐信息