CultureInfoUtilities Class
Provides utility methods for working with CultureInfo.
public static class CultureInfoUtilitiesMethods
| Name | Description |
|---|---|
| GetCulture(string?) | Gets a culture by name or LCID, returning null if not found. |
| GetNeutralCulture(CultureInfo) | Gets the neutral culture for a specific culture (e.g., "en" for "en-US"). |
| NeutralEquals(CultureInfo, CultureInfo) | Determines whether two cultures have the same neutral culture. |
| SetCurrentThreadCulture(CultureInfo) | Sets the current thread's culture and UI culture. |
| UseCulture(CultureInfo, Action) | Executes an action with a temporary culture, then restores the original culture. |
| UseCulture(string, Action) | Executes an action with a temporary culture specified by name, then restores the original culture. |
| UseCulture<T>(CultureInfo, Func<T>) | Executes a function with a temporary culture, then restores the original culture and returns the result. |
| UseCulture<T>(string, Func<T>) | Executes a function with a temporary culture specified by name, then restores the original culture and returns the result. |
GetCulture(string?)
CultureInfoUtilities.csGets a culture by name or LCID, returning null if not found.
public static CultureInfo? GetCulture(string? name)GetNeutralCulture(CultureInfo)
CultureInfoUtilities.csGets the neutral culture for a specific culture (e.g., "en" for "en-US").
public static CultureInfo GetNeutralCulture(this CultureInfo cultureInfo)NeutralEquals(CultureInfo, CultureInfo)
CultureInfoUtilities.csDetermines whether two cultures have the same neutral culture.
public static bool NeutralEquals(this CultureInfo a, CultureInfo b)SetCurrentThreadCulture(CultureInfo)
CultureInfoUtilities.csSets the current thread's culture and UI culture.
public static void SetCurrentThreadCulture(CultureInfo cultureInfo)Parameters
cultureInfoCultureInfo
UseCulture overloads
UseCulture(CultureInfo, Action)
CultureInfoUtilities.csExecutes an action with a temporary culture, then restores the original culture.
public static void UseCulture(CultureInfo cultureInfo, Action action)Parameters
cultureInfoCultureInfoactionAction
UseCulture(string, Action)
CultureInfoUtilities.csUseCulture<T>(CultureInfo, Func<T>)
CultureInfoUtilities.csExecutes a function with a temporary culture, then restores the original culture and returns the result.
public static T UseCulture<T>(CultureInfo cultureInfo, Func<T> action)