CountryCollection 1.1.0

.NET 5.0 .NET Core 3.1 .NET Standard 2.1 .NET Framework 4.0
Install-Package CountryCollection -Version 1.1.0
dotnet add package CountryCollection --version 1.1.0
<PackageReference Include="CountryCollection" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CountryCollection --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CountryCollection, 1.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CountryCollection as a Cake Addin
#addin nuget:?package=CountryCollection&version=1.1.0

// Install CountryCollection as a Cake Tool
#tool nuget:?package=CountryCollection&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

.Contains(code)

string code = "US";
bool valid = CountryCollection.Contains(code);  // True

.Contains(code)

string lowerCased = "us";
bool valid = CountryCollection.Contains(lowerCased);  // True

.Contains(code)

int numericCode = 840;
bool valid = CountryCollection.Contains(numericCode);  // True

.Normalize(code)

string iso2DigitCode = "us";
string code = CountryCollection.Normalize(iso2DigitCode);  // "US"

.Normalize(code)

string iso3DigitCode = "usa";
string code = CountryCollection.Normalize(iso3DigitCode);  // "USA"

.Normalize(code)

int numericCode = 32;
string code = CountryCollection.Normalize(numericCode);  // "032" (Argentina)

.Normalize(code)

string invalidCode = "xyz";
string code = CountryCollection.Normalize(invalidCode);  // null

.Normalize(code)

int numericCode = 99999;
string code = CountryCollection.Normalize(numericCode);  // null

.GetCountry(code)

string code = "US";
var country = CountryCollection.GetCountry(code);  // { "IsoAlpha2Code":"US", "IsoAlpha3Code":"USA", "IsoNumeric":840, "IsoEnglishShortName":"United States of America (the)", "Name":"United States" }

.GetCountry(code)

string invalidCode = "XYZ";
var country = CountryCollection.GetCountry(code);  // null

instance.[code]

string code = "US";
var country = new CountryCollection[code];  // { "IsoAlpha2Code":"US", "IsoAlpha3Code":"USA", "IsoNumeric":840, "IsoEnglishShortName":"United States of America (the)", "Name":"United States" }

instance.Add(isoAlpha2Code, isoAlpha3Code, isoNumeric, isoName)

var countries = new CountryCollection();
countries.Add("ZZ", "ZZZ", 999, "New Country");

instance.Remove(code)

var code = "ZZ";
var countries = new CountryCollection();
countries.Remove(code);

Update CountryInfo.Name and CountryInfo.FullName

string code = "US";
var country = new CountryCollection[code];

country.Name = "UNITED STATES";
country.FullName = "UNITED STATES OF AMERICA";
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 184 11/19/2021
1.0.1 180 11/14/2021
1.0.0 189 11/14/2021

* Added full names
* Added device-agonostic (general) names
* Added indexer for getting the country by code
* Added static enumeration (.Values)
* Made all non-ISO names user-editable