小编nel*_*Gti的帖子

获取分配给服务器的所有IP

我在这个答案上遇到了一个代码片段:在控制台应用程序中获取IP地址

using System; 
using System.Net; 


namespace ConsoleTest 
{ 
    class Program 
    { 
        static void Main() 
        { 
            String strHostName = string.Empty; 
            // Getting Ip address of local machine... 
            // First get the host name of local machine. 
            strHostName = Dns.GetHostName(); 
            Console.WriteLine("Local Machine's Host Name: " + strHostName); 
            // Then using host name, get the IP address list.. 
            IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); 
            IPAddress[] addr = ipEntry.AddressList; 

            for (int i = 0; i < addr.Length; i++) 
            { 
                Console.WriteLine("IP Address {0}: {1} ", i, …
Run Code Online (Sandbox Code Playgroud)

.net c# dns wmi

6
推荐指数
1
解决办法
1430
查看次数

标签 统计

.net ×1

c# ×1

dns ×1

wmi ×1