From da49e50034ae1d1a49bc543c1d01993b4cc4ed40 Mon Sep 17 00:00:00 2001 From: Nelson Nobre Date: Fri, 5 Jul 2024 20:05:30 +0100 Subject: [PATCH] feat: Added dictionary for country collection --- Country.cs | 516 +++++++++++++++++++++++++++-------------------------- README.md | 14 ++ 2 files changed, 280 insertions(+), 250 deletions(-) diff --git a/Country.cs b/Country.cs index 51be78b..f380a43 100644 --- a/Country.cs +++ b/Country.cs @@ -3,6 +3,10 @@ * * Last check against the official ISO 3166 as on https://www.iso.org/obp/ui/#search: 8th January 2020. */ + +using System; +using System.Collections.Generic; + namespace ISO3166 { public class Country @@ -20,257 +24,269 @@ private Country(string name, string twoLetterCode, string threeLetterCode, strin NumericCode = numericCode; } - public static readonly Country[] List = new[] + public static readonly Dictionary Countries = new Dictionary(StringComparer.OrdinalIgnoreCase) { - new Country("Afghanistan", "AF", "AFG", "004"), - new Country("Albania", "AL", "ALB", "008"), - new Country("Algeria", "DZ", "DZA", "012"), - new Country("American Samoa", "AS", "ASM", "016"), - new Country("Andorra", "AD", "AND", "020"), - new Country("Angola", "AO", "AGO", "024"), - new Country("Anguilla", "AI", "AIA", "660"), - new Country("Antarctica", "AQ", "ATA", "010"), - new Country("Antigua and Barbuda", "AG", "ATG", "028"), - new Country("Argentina", "AR", "ARG", "032"), - new Country("Armenia", "AM", "ARM", "051"), - new Country("Aruba", "AW", "ABW", "533"), - new Country("Australia", "AU", "AUS", "036"), - new Country("Austria", "AT", "AUT", "040"), - new Country("Azerbaijan", "AZ", "AZE", "031"), - new Country("Bahamas", "BS", "BHS", "044"), - new Country("Bahrain", "BH", "BHR", "048"), - new Country("Bangladesh", "BD", "BGD", "050"), - new Country("Barbados", "BB", "BRB", "052"), - new Country("Belarus", "BY", "BLR", "112"), - new Country("Belgium", "BE", "BEL", "056"), - new Country("Belize", "BZ", "BLZ", "084"), - new Country("Benin", "BJ", "BEN", "204"), - new Country("Bermuda", "BM", "BMU", "060"), - new Country("Bhutan", "BT", "BTN", "064"), - new Country("Bolivia, Plurinational State of", "BO", "BOL", "068"), - new Country("Bonaire, Sint Eustatius and Saba", "BQ", "BES", "535"), - new Country("Bosnia and Herzegovina", "BA", "BIH", "070"), - new Country("Botswana", "BW", "BWA", "072"), - new Country("Bouvet Island", "BV", "BVT", "074"), - new Country("Brazil", "BR", "BRA", "076"), - new Country("British Indian Ocean Territory", "IO", "IOT", "086"), - new Country("Brunei Darussalam", "BN", "BRN", "096"), - new Country("Bulgaria", "BG", "BGR", "100"), - new Country("Burkina Faso", "BF", "BFA", "854"), - new Country("Burundi", "BI", "BDI", "108"), - new Country("Cabo Verde", "CV", "CPV", "132"), - new Country("Cambodia", "KH", "KHM", "116"), - new Country("Cameroon", "CM", "CMR", "120"), - new Country("Canada", "CA", "CAN", "124"), - new Country("Cayman Islands", "KY", "CYM", "136"), - new Country("Central African Republic", "CF", "CAF", "140"), - new Country("Chad", "TD", "TCD", "148"), - new Country("Chile", "CL", "CHL", "152"), - new Country("China", "CN", "CHN", "156"), - new Country("Christmas Island", "CX", "CXR", "162"), - new Country("Cocos (Keeling) Islands", "CC", "CCK", "166"), - new Country("Colombia", "CO", "COL", "170"), - new Country("Comoros", "KM", "COM", "174"), - new Country("Congo", "CG", "COG", "178"), - new Country("Congo, the Democratic Republic of the", "CD", "COD", "180"), - new Country("Cook Islands", "CK", "COK", "184"), - new Country("Costa Rica", "CR", "CRI", "188"), - new Country("Côte d'Ivoire", "CI", "CIV", "384"), - new Country("Croatia", "HR", "HRV", "191"), - new Country("Cuba", "CU", "CUB", "192"), - new Country("Curaçao", "CW", "CUW", "531"), - new Country("Cyprus", "CY", "CYP", "196"), - new Country("Czechia", "CZ", "CZE", "203"), - new Country("Denmark", "DK", "DNK", "208"), - new Country("Djibouti", "DJ", "DJI", "262"), - new Country("Dominica", "DM", "DMA", "212"), - new Country("Dominican Republic", "DO", "DOM", "214"), - new Country("Ecuador", "EC", "ECU", "218"), - new Country("Egypt", "EG", "EGY", "818"), - new Country("El Salvador", "SV", "SLV", "222"), - new Country("Equatorial Guinea", "GQ", "GNQ", "226"), - new Country("Eritrea", "ER", "ERI", "232"), - new Country("Estonia", "EE", "EST", "233"), - new Country("Eswatini", "SZ", "SWZ", "748"), - new Country("Ethiopia", "ET", "ETH", "231"), - new Country("Falkland Islands (Malvinas)", "FK", "FLK", "238"), - new Country("Faroe Islands", "FO", "FRO", "234"), - new Country("Fiji", "FJ", "FJI", "242"), - new Country("Finland", "FI", "FIN", "246"), - new Country("France", "FR", "FRA", "250"), - new Country("French Guiana", "GF", "GUF", "254"), - new Country("French Polynesia", "PF", "PYF", "258"), - new Country("French Southern Territories", "TF", "ATF", "260"), - new Country("Gabon", "GA", "GAB", "266"), - new Country("Gambia", "GM", "GMB", "270"), - new Country("Georgia", "GE", "GEO", "268"), - new Country("Germany", "DE", "DEU", "276"), - new Country("Ghana", "GH", "GHA", "288"), - new Country("Gibraltar", "GI", "GIB", "292"), - new Country("Greece", "GR", "GRC", "300"), - new Country("Greenland", "GL", "GRL", "304"), - new Country("Grenada", "GD", "GRD", "308"), - new Country("Guadeloupe", "GP", "GLP", "312"), - new Country("Guam", "GU", "GUM", "316"), - new Country("Guatemala", "GT", "GTM", "320"), - new Country("Guernsey", "GG", "GGY", "831"), - new Country("Guinea", "GN", "GIN", "324"), - new Country("Guinea-Bissau", "GW", "GNB", "624"), - new Country("Guyana", "GY", "GUY", "328"), - new Country("Haiti", "HT", "HTI", "332"), - new Country("Heard Island and McDonald Islands", "HM", "HMD", "334"), - new Country("Holy See", "VA", "VAT", "336"), - new Country("Honduras", "HN", "HND", "340"), - new Country("Hong Kong", "HK", "HKG", "344"), - new Country("Hungary", "HU", "HUN", "348"), - new Country("Iceland", "IS", "ISL", "352"), - new Country("India", "IN", "IND", "356"), - new Country("Indonesia", "ID", "IDN", "360"), - new Country("Iran, Islamic Republic of", "IR", "IRN", "364"), - new Country("Iraq", "IQ", "IRQ", "368"), - new Country("Ireland", "IE", "IRL", "372"), - new Country("Isle of Man", "IM", "IMN", "833"), - new Country("Israel", "IL", "ISR", "376"), - new Country("Italy", "IT", "ITA", "380"), - new Country("Jamaica", "JM", "JAM", "388"), - new Country("Japan", "JP", "JPN", "392"), - new Country("Jersey", "JE", "JEY", "832"), - new Country("Jordan", "JO", "JOR", "400"), - new Country("Kazakhstan", "KZ", "KAZ", "398"), - new Country("Kenya", "KE", "KEN", "404"), - new Country("Kiribati", "KI", "KIR", "296"), - new Country("Korea, Democratic People's Republic of", "KP", "PRK", "408"), - new Country("Korea, Republic of", "KR", "KOR", "410"), - new Country("Kuwait", "KW", "KWT", "414"), - new Country("Kyrgyzstan", "KG", "KGZ", "417"), - new Country("Lao People's Democratic Republic", "LA", "LAO", "418"), - new Country("Latvia", "LV", "LVA", "428"), - new Country("Lebanon", "LB", "LBN", "422"), - new Country("Lesotho", "LS", "LSO", "426"), - new Country("Liberia", "LR", "LBR", "430"), - new Country("Libya", "LY", "LBY", "434"), - new Country("Liechtenstein", "LI", "LIE", "438"), - new Country("Lithuania", "LT", "LTU", "440"), - new Country("Luxembourg", "LU", "LUX", "442"), - new Country("Macao", "MO", "MAC", "446"), - new Country("Madagascar", "MG", "MDG", "450"), - new Country("Malawi", "MW", "MWI", "454"), - new Country("Malaysia", "MY", "MYS", "458"), - new Country("Maldives", "MV", "MDV", "462"), - new Country("Mali", "ML", "MLI", "466"), - new Country("Malta", "MT", "MLT", "470"), - new Country("Marshall Islands", "MH", "MHL", "584"), - new Country("Martinique", "MQ", "MTQ", "474"), - new Country("Mauritania", "MR", "MRT", "478"), - new Country("Mauritius", "MU", "MUS", "480"), - new Country("Mayotte", "YT", "MYT", "175"), - new Country("Mexico", "MX", "MEX", "484"), - new Country("Micronesia, Federated States of", "FM", "FSM", "583"), - new Country("Moldova, Republic of", "MD", "MDA", "498"), - new Country("Monaco", "MC", "MCO", "492"), - new Country("Mongolia", "MN", "MNG", "496"), - new Country("Montenegro", "ME", "MNE", "499"), - new Country("Montserrat", "MS", "MSR", "500"), - new Country("Morocco", "MA", "MAR", "504"), - new Country("Mozambique", "MZ", "MOZ", "508"), - new Country("Myanmar", "MM", "MMR", "104"), - new Country("Namibia", "NA", "NAM", "516"), - new Country("Nauru", "NR", "NRU", "520"), - new Country("Nepal", "NP", "NPL", "524"), - new Country("Netherlands", "NL", "NLD", "528"), - new Country("New Caledonia", "NC", "NCL", "540"), - new Country("New Zealand", "NZ", "NZL", "554"), - new Country("Nicaragua", "NI", "NIC", "558"), - new Country("Niger", "NE", "NER", "562"), - new Country("Nigeria", "NG", "NGA", "566"), - new Country("Niue", "NU", "NIU", "570"), - new Country("Norfolk Island", "NF", "NFK", "574"), - new Country("Northern Mariana Islands", "MP", "MNP", "580"), - new Country("North Macedonia", "MK", "MKD", "807"), - new Country("Norway", "NO", "NOR", "578"), - new Country("Oman", "OM", "OMN", "512"), - new Country("Pakistan", "PK", "PAK", "586"), - new Country("Palau", "PW", "PLW", "585"), - new Country("Palestine, State of", "PS", "PSE", "275"), - new Country("Panama", "PA", "PAN", "591"), - new Country("Papua New Guinea", "PG", "PNG", "598"), - new Country("Paraguay", "PY", "PRY", "600"), - new Country("Peru", "PE", "PER", "604"), - new Country("Philippines", "PH", "PHL", "608"), - new Country("Pitcairn", "PN", "PCN", "612"), - new Country("Poland", "PL", "POL", "616"), - new Country("Portugal", "PT", "PRT", "620"), - new Country("Puerto Rico", "PR", "PRI", "630"), - new Country("Qatar", "QA", "QAT", "634"), - new Country("Réunion", "RE", "REU", "638"), - new Country("Romania", "RO", "ROU", "642"), - new Country("Russian Federation", "RU", "RUS", "643"), - new Country("Rwanda", "RW", "RWA", "646"), - new Country("Saint Barthélemy", "BL", "BLM", "652"), - new Country("Saint Helena, Ascension and Tristan da Cunha", "SH", "SHN", "654"), - new Country("Saint Kitts and Nevis", "KN", "KNA", "659"), - new Country("Saint Lucia", "LC", "LCA", "662"), - new Country("Saint Martin (French part)", "MF", "MAF", "663"), - new Country("Saint Pierre and Miquelon", "PM", "SPM", "666"), - new Country("Saint Vincent and the Grenadines", "VC", "VCT", "670"), - new Country("Samoa", "WS", "WSM", "882"), - new Country("San Marino", "SM", "SMR", "674"), - new Country("Sao Tome and Principe", "ST", "STP", "678"), - new Country("Saudi Arabia", "SA", "SAU", "682"), - new Country("Senegal", "SN", "SEN", "686"), - new Country("Serbia", "RS", "SRB", "688"), - new Country("Seychelles", "SC", "SYC", "690"), - new Country("Sierra Leone", "SL", "SLE", "694"), - new Country("Singapore", "SG", "SGP", "702"), - new Country("Sint Maarten (Dutch part)", "SX", "SXM", "534"), - new Country("Slovakia", "SK", "SVK", "703"), - new Country("Slovenia", "SI", "SVN", "705"), - new Country("Solomon Islands", "SB", "SLB", "090"), - new Country("Somalia", "SO", "SOM", "706"), - new Country("South Africa", "ZA", "ZAF", "710"), - new Country("South Georgia and the South Sandwich Islands", "GS", "SGS", "239"), - new Country("South Sudan", "SS", "SSD", "728"), - new Country("Spain", "ES", "ESP", "724"), - new Country("Sri Lanka", "LK", "LKA", "144"), - new Country("Sudan", "SD", "SDN", "729"), - new Country("Suriname", "SR", "SUR", "740"), - new Country("Svalbard and Jan Mayen", "SJ", "SJM", "744"), - new Country("Sweden", "SE", "SWE", "752"), - new Country("Switzerland", "CH", "CHE", "756"), - new Country("Syrian Arab Republic", "SY", "SYR", "760"), - new Country("Taiwan, Province of China", "TW", "TWN", "158"), - new Country("Tajikistan", "TJ", "TJK", "762"), - new Country("Tanzania, United Republic of", "TZ", "TZA", "834"), - new Country("Thailand", "TH", "THA", "764"), - new Country("Timor-Leste", "TL", "TLS", "626"), - new Country("Togo", "TG", "TGO", "768"), - new Country("Tokelau", "TK", "TKL", "772"), - new Country("Tonga", "TO", "TON", "776"), - new Country("Trinidad and Tobago", "TT", "TTO", "780"), - new Country("Tunisia", "TN", "TUN", "788"), - new Country("Turkey", "TR", "TUR", "792"), - new Country("Turkmenistan", "TM", "TKM", "795"), - new Country("Turks and Caicos Islands", "TC", "TCA", "796"), - new Country("Tuvalu", "TV", "TUV", "798"), - new Country("Uganda", "UG", "UGA", "800"), - new Country("Ukraine", "UA", "UKR", "804"), - new Country("United Arab Emirates", "AE", "ARE", "784"), - new Country("United Kingdom of Great Britain and Northern Ireland", "GB", "GBR", "826"), - new Country("United States of America", "US", "USA", "840"), - new Country("United States Minor Outlying Islands", "UM", "UMI", "581"), - new Country("Uruguay", "UY", "URY", "858"), - new Country("Uzbekistan", "UZ", "UZB", "860"), - new Country("Vanuatu", "VU", "VUT", "548"), - new Country("Venezuela, Bolivarian Republic of", "VE", "VEN", "862"), - new Country("Viet Nam", "VN", "VNM", "704"), - new Country("Virgin Islands, British", "VG", "VGB", "092"), - new Country("Virgin Islands, U.S.", "VI", "VIR", "850"), - new Country("Wallis and Futuna", "WF", "WLF", "876"), - new Country("Western Sahara", "EH", "ESH", "732"), - new Country("Yemen", "YE", "YEM", "887"), - new Country("Zambia", "ZM", "ZMB", "894"), - new Country("Zimbabwe", "ZW", "ZWE", "716"), - new Country("Åland Islands", "AX", "ALA", "248") + ["AF"] = new Country("Afghanistan", "AF", "AFG", "004"), + ["AL"] = new Country("Albania", "AL", "ALB", "008"), + ["DZ"] = new Country("Algeria", "DZ", "DZA", "012"), + ["AS"] = new Country("American Samoa", "AS", "ASM", "016"), + ["AD"] = new Country("Andorra", "AD", "AND", "020"), + ["AO"] = new Country("Angola", "AO", "AGO", "024"), + ["AI"] = new Country("Anguilla", "AI", "AIA", "660"), + ["AQ"] = new Country("Antarctica", "AQ", "ATA", "010"), + ["AG"] = new Country("Antigua and Barbuda", "AG", "ATG", "028"), + ["AR"] = new Country("Argentina", "AR", "ARG", "032"), + ["AM"] = new Country("Armenia", "AM", "ARM", "051"), + ["AW"] = new Country("Aruba", "AW", "ABW", "533"), + ["AU"] = new Country("Australia", "AU", "AUS", "036"), + ["AT"] = new Country("Austria", "AT", "AUT", "040"), + ["AZ"] = new Country("Azerbaijan", "AZ", "AZE", "031"), + ["BS"] = new Country("Bahamas", "BS", "BHS", "044"), + ["BH"] = new Country("Bahrain", "BH", "BHR", "048"), + ["BD"] = new Country("Bangladesh", "BD", "BGD", "050"), + ["BB"] = new Country("Barbados", "BB", "BRB", "052"), + ["BY"] = new Country("Belarus", "BY", "BLR", "112"), + ["BE"] = new Country("Belgium", "BE", "BEL", "056"), + ["BZ"] = new Country("Belize", "BZ", "BLZ", "084"), + ["BJ"] = new Country("Benin", "BJ", "BEN", "204"), + ["BM"] = new Country("Bermuda", "BM", "BMU", "060"), + ["BT"] = new Country("Bhutan", "BT", "BTN", "064"), + ["BO"] = new Country("Bolivia, Plurinational State of", "BO", "BOL", "068"), + ["BQ"] = new Country("Bonaire, Sint Eustatius and Saba", "BQ", "BES", "535"), + ["BA"] = new Country("Bosnia and Herzegovina", "BA", "BIH", "070"), + ["BW"] = new Country("Botswana", "BW", "BWA", "072"), + ["BV"] = new Country("Bouvet Island", "BV", "BVT", "074"), + ["BR"] = new Country("Brazil", "BR", "BRA", "076"), + ["IO"] = new Country("British Indian Ocean Territory", "IO", "IOT", "086"), + ["BN"] = new Country("Brunei Darussalam", "BN", "BRN", "096"), + ["BG"] = new Country("Bulgaria", "BG", "BGR", "100"), + ["BF"] = new Country("Burkina Faso", "BF", "BFA", "854"), + ["BI"] = new Country("Burundi", "BI", "BDI", "108"), + ["CV"] = new Country("Cabo Verde", "CV", "CPV", "132"), + ["KH"] = new Country("Cambodia", "KH", "KHM", "116"), + ["CM"] = new Country("Cameroon", "CM", "CMR", "120"), + ["CA"] = new Country("Canada", "CA", "CAN", "124"), + ["KY"] = new Country("Cayman Islands", "KY", "CYM", "136"), + ["CF"] = new Country("Central African Republic", "CF", "CAF", "140"), + ["TD"] = new Country("Chad", "TD", "TCD", "148"), + ["CL"] = new Country("Chile", "CL", "CHL", "152"), + ["CN"] = new Country("China", "CN", "CHN", "156"), + ["CX"] = new Country("Christmas Island", "CX", "CXR", "162"), + ["CC"] = new Country("Cocos (Keeling) Islands", "CC", "CCK", "166"), + ["CO"] = new Country("Colombia", "CO", "COL", "170"), + ["KM"] = new Country("Comoros", "KM", "COM", "174"), + ["CG"] = new Country("Congo", "CG", "COG", "178"), + ["CD"] = new Country("Congo, the Democratic Republic of the", "CD", "COD", "180"), + ["CK"] = new Country("Cook Islands", "CK", "COK", "184"), + ["CR"] = new Country("Costa Rica", "CR", "CRI", "188"), + ["CI"] = new Country("Côte d'Ivoire", "CI", "CIV", "384"), + ["HR"] = new Country("Croatia", "HR", "HRV", "191"), + ["CU"] = new Country("Cuba", "CU", "CUB", "192"), + ["CW"] = new Country("Curaçao", "CW", "CUW", "531"), + ["CY"] = new Country("Cyprus", "CY", "CYP", "196"), + ["CZ"] = new Country("Czechia", "CZ", "CZE", "203"), + ["DK"] = new Country("Denmark", "DK", "DNK", "208"), + ["DJ"] = new Country("Djibouti", "DJ", "DJI", "262"), + ["DM"] = new Country("Dominica", "DM", "DMA", "212"), + ["DO"] = new Country("Dominican Republic", "DO", "DOM", "214"), + ["EC"] = new Country("Ecuador", "EC", "ECU", "218"), + ["EG"] = new Country("Egypt", "EG", "EGY", "818"), + ["SV"] = new Country("El Salvador", "SV", "SLV", "222"), + ["GQ"] = new Country("Equatorial Guinea", "GQ", "GNQ", "226"), + ["ER"] = new Country("Eritrea", "ER", "ERI", "232"), + ["EE"] = new Country("Estonia", "EE", "EST", "233"), + ["SZ"] = new Country("Eswatini", "SZ", "SWZ", "748"), + ["ET"] = new Country("Ethiopia", "ET", "ETH", "231"), + ["FK"] = new Country("Falkland Islands (Malvinas)", "FK", "FLK", "238"), + ["FO"] = new Country("Faroe Islands", "FO", "FRO", "234"), + ["FJ"] = new Country("Fiji", "FJ", "FJI", "242"), + ["FI"] = new Country("Finland", "FI", "FIN", "246"), + ["FR"] = new Country("France", "FR", "FRA", "250"), + ["GF"] = new Country("French Guiana", "GF", "GUF", "254"), + ["PF"] = new Country("French Polynesia", "PF", "PYF", "258"), + ["TF"] = new Country("French Southern Territories", "TF", "ATF", "260"), + ["GA"] = new Country("Gabon", "GA", "GAB", "266"), + ["GM"] = new Country("Gambia", "GM", "GMB", "270"), + ["GE"] = new Country("Georgia", "GE", "GEO", "268"), + ["DE"] = new Country("Germany", "DE", "DEU", "276"), + ["GH"] = new Country("Ghana", "GH", "GHA", "288"), + ["GI"] = new Country("Gibraltar", "GI", "GIB", "292"), + ["GR"] = new Country("Greece", "GR", "GRC", "300"), + ["GL"] = new Country("Greenland", "GL", "GRL", "304"), + ["GD"] = new Country("Grenada", "GD", "GRD", "308"), + ["GP"] = new Country("Guadeloupe", "GP", "GLP", "312"), + ["GU"] = new Country("Guam", "GU", "GUM", "316"), + ["GT"] = new Country("Guatemala", "GT", "GTM", "320"), + ["GG"] = new Country("Guernsey", "GG", "GGY", "831"), + ["GN"] = new Country("Guinea", "GN", "GIN", "324"), + ["GW"] = new Country("Guinea-Bissau", "GW", "GNB", "624"), + ["GY"] = new Country("Guyana", "GY", "GUY", "328"), + ["HT"] = new Country("Haiti", "HT", "HTI", "332"), + ["HM"] = new Country("Heard Island and McDonald Islands", "HM", "HMD", "334"), + ["VA"] = new Country("Holy See", "VA", "VAT", "336"), + ["HN"] = new Country("Honduras", "HN", "HND", "340"), + ["HK"] = new Country("Hong Kong", "HK", "HKG", "344"), + ["HU"] = new Country("Hungary", "HU", "HUN", "348"), + ["IS"] = new Country("Iceland", "IS", "ISL", "352"), + ["IN"] = new Country("India", "IN", "IND", "356"), + ["ID"] = new Country("Indonesia", "ID", "IDN", "360"), + ["IR"] = new Country("Iran, Islamic Republic of", "IR", "IRN", "364"), + ["IQ"] = new Country("Iraq", "IQ", "IRQ", "368"), + ["IE"] = new Country("Ireland", "IE", "IRL", "372"), + ["IM"] = new Country("Isle of Man", "IM", "IMN", "833"), + ["IL"] = new Country("Israel", "IL", "ISR", "376"), + ["IT"] = new Country("Italy", "IT", "ITA", "380"), + ["JM"] = new Country("Jamaica", "JM", "JAM", "388"), + ["JP"] = new Country("Japan", "JP", "JPN", "392"), + ["JE"] = new Country("Jersey", "JE", "JEY", "832"), + ["JO"] = new Country("Jordan", "JO", "JOR", "400"), + ["KZ"] = new Country("Kazakhstan", "KZ", "KAZ", "398"), + ["KE"] = new Country("Kenya", "KE", "KEN", "404"), + ["KI"] = new Country("Kiribati", "KI", "KIR", "296"), + ["KP"] = new Country("Korea, Democratic People's Republic of", "KP", "PRK", "408"), + ["KR"] = new Country("Korea, Republic of", "KR", "KOR", "410"), + ["KW"] = new Country("Kuwait", "KW", "KWT", "414"), + ["KG"] = new Country("Kyrgyzstan", "KG", "KGZ", "417"), + ["LA"] = new Country("Lao People's Democratic Republic", "LA", "LAO", "418"), + ["LV"] = new Country("Latvia", "LV", "LVA", "428"), + ["LB"] = new Country("Lebanon", "LB", "LBN", "422"), + ["LS"] = new Country("Lesotho", "LS", "LSO", "426"), + ["LR"] = new Country("Liberia", "LR", "LBR", "430"), + ["LY"] = new Country("Libya", "LY", "LBY", "434"), + ["LI"] = new Country("Liechtenstein", "LI", "LIE", "438"), + ["LT"] = new Country("Lithuania", "LT", "LTU", "440"), + ["LU"] = new Country("Luxembourg", "LU", "LUX", "442"), + ["MO"] = new Country("Macao", "MO", "MAC", "446"), + ["MG"] = new Country("Madagascar", "MG", "MDG", "450"), + ["MW"] = new Country("Malawi", "MW", "MWI", "454"), + ["MY"] = new Country("Malaysia", "MY", "MYS", "458"), + ["MV"] = new Country("Maldives", "MV", "MDV", "462"), + ["ML"] = new Country("Mali", "ML", "MLI", "466"), + ["MT"] = new Country("Malta", "MT", "MLT", "470"), + ["MH"] = new Country("Marshall Islands", "MH", "MHL", "584"), + ["MQ"] = new Country("Martinique", "MQ", "MTQ", "474"), + ["MR"] = new Country("Mauritania", "MR", "MRT", "478"), + ["MU"] = new Country("Mauritius", "MU", "MUS", "480"), + ["YT"] = new Country("Mayotte", "YT", "MYT", "175"), + ["MX"] = new Country("Mexico", "MX", "MEX", "484"), + ["FM"] = new Country("Micronesia, Federated States of", "FM", "FSM", "583"), + ["MD"] = new Country("Moldova, Republic of", "MD", "MDA", "498"), + ["MC"] = new Country("Monaco", "MC", "MCO", "492"), + ["MN"] = new Country("Mongolia", "MN", "MNG", "496"), + ["ME"] = new Country("Montenegro", "ME", "MNE", "499"), + ["MS"] = new Country("Montserrat", "MS", "MSR", "500"), + ["MA"] = new Country("Morocco", "MA", "MAR", "504"), + ["MZ"] = new Country("Mozambique", "MZ", "MOZ", "508"), + ["MM"] = new Country("Myanmar", "MM", "MMR", "104"), + ["NA"] = new Country("Namibia", "NA", "NAM", "516"), + ["NR"] = new Country("Nauru", "NR", "NRU", "520"), + ["NP"] = new Country("Nepal", "NP", "NPL", "524"), + ["NL"] = new Country("Netherlands", "NL", "NLD", "528"), + ["NC"] = new Country("New Caledonia", "NC", "NCL", "540"), + ["NZ"] = new Country("New Zealand", "NZ", "NZL", "554"), + ["NI"] = new Country("Nicaragua", "NI", "NIC", "558"), + ["NE"] = new Country("Niger", "NE", "NER", "562"), + ["NG"] = new Country("Nigeria", "NG", "NGA", "566"), + ["NU"] = new Country("Niue", "NU", "NIU", "570"), + ["NF"] = new Country("Norfolk Island", "NF", "NFK", "574"), + ["MP"] = new Country("Northern Mariana Islands", "MP", "MNP", "580"), + ["MK"] = new Country("North Macedonia", "MK", "MKD", "807"), + ["NO"] = new Country("Norway", "NO", "NOR", "578"), + ["OM"] = new Country("Oman", "OM", "OMN", "512"), + ["PK"] = new Country("Pakistan", "PK", "PAK", "586"), + ["PW"] = new Country("Palau", "PW", "PLW", "585"), + ["PS"] = new Country("Palestine, State of", "PS", "PSE", "275"), + ["PA"] = new Country("Panama", "PA", "PAN", "591"), + ["PG"] = new Country("Papua New Guinea", "PG", "PNG", "598"), + ["PY"] = new Country("Paraguay", "PY", "PRY", "600"), + ["PE"] = new Country("Peru", "PE", "PER", "604"), + ["PH"] = new Country("Philippines", "PH", "PHL", "608"), + ["PN"] = new Country("Pitcairn", "PN", "PCN", "612"), + ["PL"] = new Country("Poland", "PL", "POL", "616"), + ["PT"] = new Country("Portugal", "PT", "PRT", "620"), + ["PR"] = new Country("Puerto Rico", "PR", "PRI", "630"), + ["QA"] = new Country("Qatar", "QA", "QAT", "634"), + ["RE"] = new Country("Réunion", "RE", "REU", "638"), + ["RO"] = new Country("Romania", "RO", "ROU", "642"), + ["RU"] = new Country("Russian Federation", "RU", "RUS", "643"), + ["RW"] = new Country("Rwanda", "RW", "RWA", "646"), + ["BL"] = new Country("Saint Barthélemy", "BL", "BLM", "652"), + ["SH"] = new Country("Saint Helena, Ascension and Tristan da Cunha", "SH", "SHN", "654"), + ["KN"] = new Country("Saint Kitts and Nevis", "KN", "KNA", "659"), + ["LC"] = new Country("Saint Lucia", "LC", "LCA", "662"), + ["MF"] = new Country("Saint Martin (French part)", "MF", "MAF", "663"), + ["PM"] = new Country("Saint Pierre and Miquelon", "PM", "SPM", "666"), + ["VC"] = new Country("Saint Vincent and the Grenadines", "VC", "VCT", "670"), + ["WS"] = new Country("Samoa", "WS", "WSM", "882"), + ["SM"] = new Country("San Marino", "SM", "SMR", "674"), + ["ST"] = new Country("Sao Tome and Principe", "ST", "STP", "678"), + ["SA"] = new Country("Saudi Arabia", "SA", "SAU", "682"), + ["SN"] = new Country("Senegal", "SN", "SEN", "686"), + ["RS"] = new Country("Serbia", "RS", "SRB", "688"), + ["SC"] = new Country("Seychelles", "SC", "SYC", "690"), + ["SL"] = new Country("Sierra Leone", "SL", "SLE", "694"), + ["SG"] = new Country("Singapore", "SG", "SGP", "702"), + ["SX"] = new Country("Sint Maarten (Dutch part)", "SX", "SXM", "534"), + ["SK"] = new Country("Slovakia", "SK", "SVK", "703"), + ["SI"] = new Country("Slovenia", "SI", "SVN", "705"), + ["SB"] = new Country("Solomon Islands", "SB", "SLB", "090"), + ["SO"] = new Country("Somalia", "SO", "SOM", "706"), + ["ZA"] = new Country("South Africa", "ZA", "ZAF", "710"), + ["GS"] = new Country("South Georgia and the South Sandwich Islands", "GS", "SGS", "239"), + ["SS"] = new Country("South Sudan", "SS", "SSD", "728"), + ["ES"] = new Country("Spain", "ES", "ESP", "724"), + ["LK"] = new Country("Sri Lanka", "LK", "LKA", "144"), + ["SD"] = new Country("Sudan", "SD", "SDN", "729"), + ["SR"] = new Country("Suriname", "SR", "SUR", "740"), + ["SJ"] = new Country("Svalbard and Jan Mayen", "SJ", "SJM", "744"), + ["SE"] = new Country("Sweden", "SE", "SWE", "752"), + ["CH"] = new Country("Switzerland", "CH", "CHE", "756"), + ["SY"] = new Country("Syrian Arab Republic", "SY", "SYR", "760"), + ["TW"] = new Country("Taiwan, Province of China", "TW", "TWN", "158"), + ["TJ"] = new Country("Tajikistan", "TJ", "TJK", "762"), + ["TZ"] = new Country("Tanzania, United Republic of", "TZ", "TZA", "834"), + ["TH"] = new Country("Thailand", "TH", "THA", "764"), + ["TL"] = new Country("Timor-Leste", "TL", "TLS", "626"), + ["TG"] = new Country("Togo", "TG", "TGO", "768"), + ["TK"] = new Country("Tokelau", "TK", "TKL", "772"), + ["TO"] = new Country("Tonga", "TO", "TON", "776"), + ["TT"] = new Country("Trinidad and Tobago", "TT", "TTO", "780"), + ["TN"] = new Country("Tunisia", "TN", "TUN", "788"), + ["TR"] = new Country("Turkey", "TR", "TUR", "792"), + ["TM"] = new Country("Turkmenistan", "TM", "TKM", "795"), + ["TC"] = new Country("Turks and Caicos Islands", "TC", "TCA", "796"), + ["TV"] = new Country("Tuvalu", "TV", "TUV", "798"), + ["UG"] = new Country("Uganda", "UG", "UGA", "800"), + ["UA"] = new Country("Ukraine", "UA", "UKR", "804"), + ["AE"] = new Country("United Arab Emirates", "AE", "ARE", "784"), + ["GB"] = new Country("United Kingdom of Great Britain and Northern Ireland", "GB", "GBR", "826"), + ["US"] = new Country("United States of America", "US", "USA", "840"), + ["UM"] = new Country("United States Minor Outlying Islands", "UM", "UMI", "581"), + ["UY"] = new Country("Uruguay", "UY", "URY", "858"), + ["UZ"] = new Country("Uzbekistan", "UZ", "UZB", "860"), + ["VU"] = new Country("Vanuatu", "VU", "VUT", "548"), + ["VE"] = new Country("Venezuela, Bolivarian Republic of", "VE", "VEN", "862"), + ["VN"] = new Country("Viet Nam", "VN", "VNM", "704"), + ["VG"] = new Country("Virgin Islands, British", "VG", "VGB", "092"), + ["VI"] = new Country("Virgin Islands, U.S.", "VI", "VIR", "850"), + ["WF"] = new Country("Wallis and Futuna", "WF", "WLF", "876"), + ["EH"] = new Country("Western Sahara", "EH", "ESH", "732"), + ["YE"] = new Country("Yemen", "YE", "YEM", "887"), + ["ZM"] = new Country("Zambia", "ZM", "ZMB", "894"), + ["ZW"] = new Country("Zimbabwe", "ZW", "ZWE", "716"), + ["AX"] = new Country("Åland Islands", "AX", "ALA", "248") }; + + + public static readonly Country[] List = new Country[Countries.Count]; + + static Country() + { + var count = 0; + foreach (var item in Countries) + { + List[count++] = item.Value; + } + } } } diff --git a/README.md b/README.md index 2a208f4..e7215a5 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ PM> Install-Package ISO3166 ```c# Country[] countries = ISO3166.Country.List; + +Dictionary countries = ISO3166.Country.Countries; ``` ## Country Model @@ -28,9 +30,21 @@ public string TwoLetterCode { get; private set; } public string ThreeLetterCode { get; private set; } public string NumericCode { get; private set; } +public static readonly Dictionary Countries = new Dictionary(StringComparer.OrdinalIgnoreCase) {...}; public static readonly Country[] List = new[] {...}; ``` +## Lookup operations + +The key is case-insensitive. + +```c# +// Country by two-letter code (ISO 3166-1 alpha-2) +Country country = ISO3166.Country.Countries["DK"]; +Country country = ISO3166.Country.Countries["dk"]; +``` + + Last check against the official ISO 3166 as on https://www.iso.org/obp/ui/#search: 8th January 2020 License: MIT