Author Topic: Country code from county name.  (Read 2309 times)

Gametaku

  • .
  • Founders
  • Posts: 168
  • Karma: +13/-4
  • .
Country code from county name.
« on: December 13, 2008, 02:18:48 AM »
the RegionalInfo class in .net takes the 2 digit Country code, and can give you the country it's for.  I need the reverse I have the country I need the code. I know that I can do it by hand but is there a premade option. 


Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: Country code from county name.
« Reply #1 on: December 13, 2008, 09:59:04 AM »
Depending on exactly what you are doing there are snippets of code for this readily available as well as txt/xml files containing the data needed. Shouldn't be too hard
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Country code from county name.
« Reply #2 on: December 13, 2008, 01:43:50 PM »
If the class already has the data isn't there a way to access the reverse? Is there a key iterator or something so you could invert the index?

Gametaku

  • .
  • Founders
  • Posts: 168
  • Karma: +13/-4
  • .
Re: Country code from county name.
« Reply #3 on: December 16, 2008, 12:00:16 AM »
I looked for a snippet of code didn't have much finding one.  Ended up coping the list of Countries and the corresponding country code and parsing through to create an array.  Did the same thing with the US states and Canada's providences. 
(Visual Studio then got around to telling me that my long lines of text are slowing the program down).

and no Perspective I could not.  The constructor for the RegionInfo class in .net takes the two letter country code and can give you the name.  I had the name,  I needed the code.