Table of Contents

Class Countries

Namespace
HeroKit.Globalization
Assembly
HeroKit.dll

Predefined countries and a registry that resolves countries by ISO code, for example in validation attributes.

public static class Countries
Inheritance
Countries
Inherited Members

Properties

All

Gets all registered countries.

public static IReadOnlyCollection<Country> All { get; }

Property Value

IReadOnlyCollection<Country>

Turkey

Gets Türkiye (TR): phone numbers, plates, postal codes, TCKN, VKN, public holidays, provinces and the Turkish lira.

public static Country Turkey { get; }

Property Value

Country

UnitedStates

Gets the United States (US): phone numbers, ZIP codes, SSN, tax IDs (SSN, ITIN, EIN), federal holidays, states and the US dollar. Vehicle plates differ by state and are not supported.

public static Country UnitedStates { get; }

Property Value

Country

Methods

Get(string)

Returns the registered country with an ISO 3166-1 alpha-2 code.

public static Country Get(string code)

Parameters

code string

The code, for example "TR". Case is ignored.

Returns

Country

The country.

Exceptions

KeyNotFoundException

No country is registered with the code.

Register(Country)

Registers a country so it can be resolved by its ISO code. A country with the same code is replaced.

public static void Register(Country country)

Parameters

country Country

The country.

TryGet(string?, out Country?)

Tries to return the registered country with an ISO 3166-1 alpha-2 code.

public static bool TryGet(string? code, out Country? country)

Parameters

code string

The code, for example "TR". Case is ignored.

country Country

The country when the method returns true.

Returns

bool

True if a country is registered with the code.