• 获取电脑名和Ip


     private string  GetHostNameAndIP( bool  isv4Orv6)
            {
                string HostName = Dns.GetHostName();//本机名  
                string IPAddress = "";
                System.Net.IPAddress[] addressList = Dns.GetHostAddresses(HostName);//会返回所有地址,包括IPv4和IPv6   
                foreach (IPAddress ip in addressList)
                {
                    if (isv4Orv6)
                    {
                        if (ip.AddressFamily == AddressFamily.InterNetwork)
                            IPAddress = ip.ToString();
                       
                    }
                    else
                    {
                        if (ip.AddressFamily == AddressFamily.InterNetworkV6)
                            IPAddress = ip.ToString();
                    }
                   
                }
                return "{HostNmae:'" + HostName + "',Ip:'" + IPAddress + "'}";
            }

  • 相关阅读:
    oracle课堂笔记---第十九天
    oracle课堂笔记--第十八天
    oracle课堂随笔--第十七天
    oracle课堂随笔--第十六天
    oracle课堂随笔--第十五天
    oracle课堂随笔--第十四天
    oracle课堂笔记--第十三天
    oracle课堂随笔--第十一天
    Beta冲刺预备
    个人作业——软件产品分析
  • 原文地址:https://www.cnblogs.com/linsu/p/3691592.html
Copyright © 2020-2023  润新知