Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我可以从用户';s的11位电话号码,如03xx-xxxxxxx?如果可能的话,那怎么办?_C#_Android_Asp.net Mvc - Fatal编程技术网

C# 我可以从用户';s的11位电话号码,如03xx-xxxxxxx?如果可能的话,那怎么办?

C# 我可以从用户';s的11位电话号码,如03xx-xxxxxxx?如果可能的话,那怎么办?,c#,android,asp.net-mvc,C#,Android,Asp.net Mvc,我想获取用户电话号码的国家代码,他可能输入了没有国家代码(11位)的手机。如果可能的话,请帮助我。有一个很棒的库,名为libphonenumber(C#端口:),它可以将电话号码转换为有效的E.164号码。但是,您需要假定数字的来源国才能正确解析它们 public string ParsePhoneNumber(string number) { var phoneNumberUtil = PhoneNumbers.PhoneNumberUtil.GetInstance(); re

我想获取用户电话号码的国家代码,他可能输入了没有国家代码(11位)的手机。如果可能的话,请帮助我。

有一个很棒的库,名为
libphonenumber
(C#端口:),它可以将电话号码转换为有效的E.164号码。但是,您需要假定数字的来源国才能正确解析它们

public string ParsePhoneNumber(string number)
{
    var phoneNumberUtil = PhoneNumbers.PhoneNumberUtil.GetInstance();
    return phoneNumberUtil.Parse(nationalPhoneNumber, "DE");
}

你有这个能力,或者如果你想使用谷歌phonenumber库
phonenumber-numberProto=phoneUtil.parse(phone,”);int countryCode=numberProto.getCountryCode()