Exemplo n.º 1
0
        /// <summary>
        /// 获取本机的Ip地址和网卡地址,Ip地址以字符串返回,形如:192.168.1.11(动态),192.168.1.33(🔒)
        /// </summary>
        /// <param name="macAddress"></param>
        /// <returns></returns>
        public static string FormatLocalIps(out string macAddress)
        {
            string localIp = string.Empty;

            macAddress = string.Empty;
            HashSet <string> hs = new HashSet <string>();

            foreach (var item in LocalIpSet.AsEnumerable().ToArray())
            {
                if (hs.Contains(item.MACAddress))
                {
                    continue;
                }
                hs.Add(item.MACAddress);
                if (macAddress.Length != 0)
                {
                    macAddress += "," + item.MACAddress;
                    localIp    += "," + item.IPAddress + (item.DHCPEnabled ? "(动态)" : "(🔒)");
                }
                else
                {
                    macAddress = item.MACAddress;
                    localIp    = item.IPAddress + (item.DHCPEnabled ? "(动态)" : "(🔒)");
                }
            }
            return(localIp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取本机的Ip地址和网卡地址,Ip地址以字符串返回,形如:192.168.1.11(动态),192.168.1.33(🔒)
        /// </summary>
        /// <param name="macAddress"></param>
        /// <returns></returns>
        public static string FormatLocalIps(out string macAddress)
        {
            string localIp = string.Empty;

            macAddress = string.Empty;
            foreach (var item in LocalIpSet.AsEnumerable())
            {
                if (macAddress.Length != 0)
                {
                    macAddress += "," + item.MACAddress;
                    localIp    += "," + item.IPAddress + (item.DHCPEnabled ? "(动态)" : "(🔒)");
                }
                else
                {
                    macAddress = item.MACAddress;
                    localIp    = item.IPAddress + (item.DHCPEnabled ? "(动态)" : "(🔒)");
                }
            }
            return(localIp);
        }