zoukankan      html  css  js  c++  java
  • ip地址查询城市

    public bool IsExitCityByIP(string ip,out string city)
             {            
                    string[] ips = ip.Split('.');
                     double ipNum = Convert.ToDouble(ips[0]) * 16777216 + Convert.ToDouble(ips[1]) * 65536 + Convert.ToDouble(ips[2]) * 256 + Convert.ToDouble(ips[3]);
     
                    string[] cityName = { "Shenzhen", "Shanghai", "Guangzhou", "Hong Kong" };
                     IPGroupCity c = GetAddressByIPNum(ipNum);
                     city = c.City.ToString();
                     if (city != null)计算
                     {
                         for (int i = 0; i < cityName.Length; i++)
                         {
                             if (cityName[i].Equals(city))
                             {
                                 lblAddress.Text = "您查询的IP:" + txtIP.Text + "<br>IP地址位置:" + c.Country_name + "--" + city;
                                 return true;
                             }
                             else if (cityName[i].Equals(c.Country_name))
                             {
                                 lblAddress.Text = "您查询的IP:" + txtIP.Text + "<br>IP地址位置:" + c.Country_name + "--" + city;
                                 return true;
                             }
                         }
                         lblAddress.Text = "您查询的IP:" + txtIP.Text + "<br>IP地址位置:" + c.Country_name + "--" + city + "!   您没有在OpenRice所涉足的五个城市内 ";
                         return false;
                     }
                     else
                     {
                         ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('您输入的IP没有相关记录')", true);  
                         return false;
                     }
                      
            }
  • 相关阅读:
    构建之法阅读笔记01
    学习进度13
    学习进度12
    个人冲刺十
    个人冲刺九
    个人冲刺八
    学习进度11
    个人冲刺七
    个人冲刺六
    [HDU 1232 ]畅通工程
  • 原文地址:https://www.cnblogs.com/johnwang/p/3225164.html
Copyright © 2011-2022 走看看