c#获取本地IP地址

2021-01-17 09:13

阅读:441

标签:div   write   pad   ip地址   lin   本地   network   ipaddr   res   

  string ipc = "";
            string AddressIP = string.Empty;
            foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
            {
                if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
                {
                    AddressIP = _IPAddress.ToString();
                }
            }
            ipc = AddressIP;
            Console.WriteLine(ipc);

c#获取本地IP地址

标签:div   write   pad   ip地址   lin   本地   network   ipaddr   res   

原文地址:https://www.cnblogs.com/Angdybo/p/12200770.html


评论


亲,登录后才可以留言!