gpt4 book ai didi

c# - GeoIpLocation - 如何获取州和县? (或者,如何从邮政编码获取州和县)C#

转载 作者:行者123 更新时间:2023-11-30 23:25:30 24 4
gpt4 key购买 nike

我正在使用一种方法从 IP 地址获取 IipLocation 对象。这是返回 Location 对象的代码:

public IIpLocation GetIpLocation(IPAddress ipAddress)
{
ipAddress.CheckNull("ipAddress");

IIpLocation ipLocation = null;
try
{
//Try to look up the location using MaxMind.
Location location = GetMaxMindIpLocation(ipAddress);

//If the postal code is not present, then try to look it up with GeoNames.
if (location != null && (location.PostalCode == null || location.PostalCode.Equals("")))
{
location.PostalCode = GetPostalCodeFromGeoNames(location);
}

if (location != null)
{
ipLocation = new GeoIpLocation(location);
}
}
catch (NullReferenceException)
{
Log.ErrorFormat(Resources.log_maxMindLookupFailed, ipAddress);
}

return ipLocation;
}

IipLocation 对象具有以下属性:RegionRegionNameCountryCodeCity邮政编码纬度经度。但是,我需要州和县。如何从我拥有的信息中获取州和县?

最佳答案

关于c# - GeoIpLocation - 如何获取州和县? (或者,如何从邮政编码获取州和县)C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37217923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com