请检查以下从电话号码中检索区号的 c# 代码
AreaCodeMap map = new AreaCodeMap();
var areas = await _areas.GetAllAreasAsync();
SortedDictionary<int, string> sortedMapForUS = new SortedDictionary<int, string>();
foreach (var area in areas)
{
sortedMapForUS.Add(Int32.Parse(area.PhoneNoCode), area.AreaName);
}
map.readAreaCodeMap(sortedMapForUS);
var areaCode = map.Lookup(phoneUS);
if (areaCode == null)
{
throw new ApiException("No description for the area code was found", ConnectMeError.InvalidAreaCode);
}
int areaCodeKey = sortedMapForUS.FirstOrDefault(x => x.Value == areaCode).Key;
我有以下代码,我正在尝试使用电话号码:+12015555777,其格式为 e164 格式,在给出完整区域列表的情况下,它应该给我代码 201 NJ 'New Jersey',但是在检查 areaCode 时我得到'null',请以任何可能的方式建议我解决此问题。我使用 libphonenumber 的 nuget,phoneUs 的类型为 PhoneNumber。