schourode / iso3166

ISO 3166-1 country list for .NET
MIT License
76 stars 31 forks source link

feat: Added dictionary for country collection #35

Open NelsonBN opened 3 months ago

NelsonBN commented 3 months ago

The idea is to have the countries information stored in a HashTable data structure, allowing us to reduce the lookup operation from O(n) to O(1).

E.g:

Country country = ISO3166.Country.Countries["DK"];
Country country = ISO3166.Country.Countries["dk"];

Also instantiated the dictionary with StringComparer.OrdinalIgnoreCase so the lookup operation can be case-insensitive.

To prevent breaking changes, the dictionary was created as ISO3166.Country.Countries and maintained ISO3166.Country.List, initializing it based on ISO3166.Country.Countries upon first use.