CountryCodeHelper Class
Namespace: PTS.Globalization
Assembly: PTS.Globalization.dll
Static helper class with various extension methods aiding with country specific value formatting and conversions.
Syntax
[InitializeOnStart]
public static class CountryCodeHelper
Inheritance
Methods
FormatCurrency(CountryCode, Decimal)
Returns currency value formatted in accordance with conventions in specified country.
Declaration
public static string FormatCurrency(this CountryCode country, decimal value)
Parameters
Type | Name | Description |
---|---|---|
CountryCode | country | The country format the value for. |
System.Decimal | value | The value to format. |
Returns
Type | Description |
---|---|
System.String | Formatted currency value for given country |
Examples
string displayValue = CountryCode.Czechia.FormatCurrency( 1120.50 );
Console.WriteLine( $"The price is {displayValue}" ); // Outputs 1250,50 Kc
FormatDate(CountryCode, DateTime)
Returns date formatted in accordance with conventions in specified country.
Declaration
public static string FormatDate(this CountryCode country, DateTime date)
Parameters
Type | Name | Description |
---|---|---|
CountryCode | country | The country format the value for. |
System.DateTime | date |
Returns
Type | Description |
---|---|
System.String | Formatted date for given country |
FormatDateTime(CountryCode, DateTime)
Returns date and time formatted in accordance with conventions in specified country.
Declaration
public static string FormatDateTime(this CountryCode country, DateTime date)
Parameters
Type | Name | Description |
---|---|---|
CountryCode | country | The country format the value for. |
System.DateTime | date |
Returns
Type | Description |
---|---|
System.String | Formatted date time for given country |
FormatTime(CountryCode, DateTime)
Returns time formatted in accordance with conventions in specified country.
Declaration
public static string FormatTime(this CountryCode country, DateTime date)
Parameters
Type | Name | Description |
---|---|---|
CountryCode | country | The country format the value for. |
System.DateTime | date |
Returns
Type | Description |
---|---|
System.String | Formatted time for given country |
FromIsoCode(String, Boolean)
Declaration
public static CountryCode FromIsoCode(string isoCode, bool require = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | isoCode | |
System.Boolean | require |
Returns
Type | Description |
---|---|
CountryCode |
IsEuropeanUnion(CountryCode)
Determines whether a country is in European Union.
Declaration
public static bool IsEuropeanUnion(this CountryCode country)
Parameters
Type | Name | Description |
---|---|---|
CountryCode | country | The country to test. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
The membership determination is valid as of May 2019.
ToCultureInfo(CountryCode)
Gets System.Globalization.CultureInfo for given country.
Declaration
public static CultureInfo ToCultureInfo(this CountryCode country)
Parameters
Type | Name | Description |
---|---|---|
CountryCode | country | The country to get the System.Globalization.CultureInfo for. |
Returns
Type | Description |
---|---|
System.Globalization.CultureInfo | System.Globalization.CultureInfo if found; otherwise, |
ToCurrencyCode(CountryCode)
Gets CurrencyCode for given country.
Declaration
public static CurrencyCode ToCurrencyCode(this CountryCode country)
Parameters
Type | Name | Description |
---|---|---|
CountryCode | country | The country to get the CurrencyCode for. |
Returns
Type | Description |
---|---|
CurrencyCode | CurrencyCode if found; otherwise, |
ToRegionInfo(CountryCode)
Gets System.Globalization.RegionInfo for given country.
Declaration
public static RegionInfo ToRegionInfo(this CountryCode country)
Parameters
Type | Name | Description |
---|---|---|
CountryCode | country | The country to get the System.Globalization.RegionInfo for. |
Returns
Type | Description |
---|---|
System.Globalization.RegionInfo | System.Globalization.RegionInfo if found; otherwise, |