Thomas Thomas - 11 months ago 53
C# Question

Best way to get the international country ISD phone codes

I am looking for any routine which will give me the ISD code for any country. I searched Google a lot but found nothing similar. I tried to do it in this way:

public string ISDCode(string strCountryCode)
string countryCode = "";
XmlDocument xdoc = new XmlDocument();
string url = "";
url = url + "sCountryISOCode=" + strCountryCode;
countryCode = xdoc.DocumentElement.InnerText.ToString();
return countryCode;

I use this web service

but often it is not accessible. Please guide me how I can get the ISD code for any country. I will just pass country code only. For example I will pass 'CA' for Canada and the routine will give me the Canada ISO code. Please help. thanks.

Answer Source

If you don't want to use a webservice for some reason, I'd go to Wikipedia:

...or here:

...and build my own lookup table from that. In fact writing a script to generate that automatically sounds kind of fun to me. :)