1

I have created a piece of code in c# that takes an incoming phone number, and presents this as variable lineuri.

There is then an array containing each of the possible international Dialling Prefixes (e.g. 44 for the uk, 00 for the US e.t.c.

However, in order for this to function, i need to present to the user in a message box the country that the incoming call is coming from.

Essentially, i guess i need to take variable LineUri, and compare it to the Array of international number prefixes. If this matches, i then need a method of returning the Country Name from a second Array containing the names of each country?

Apologies if this is overly wordy - first time posting on this site.

If any further information is required, more than happy to help.

Appreciate any help you are able to offer - Thanks in advance!

4

1 回答 1

1

I would not use an array. You need a keyed collection:

Dictionary<string,string> countriesByDialingCode = new Dictionary<string,string>();

...

countriesByDialingCode.Add("00", "USA");
countriesByDialingCode.Add("44", "USA");

...

string country = countriesByDialingCode["44"];
于 2013-04-12T13:24:49.877 回答