CultureInfo.GetCultureInfo CultureInfo.GetCultureInfo CultureInfo.GetCultureInfo CultureInfo.GetCultureInfo Method

Definition

Retrieves a cached, read-only instance of a culture.

Overloads

GetCultureInfo(Int32) GetCultureInfo(Int32) GetCultureInfo(Int32) GetCultureInfo(Int32)

Retrieves a cached, read-only instance of a culture by using the specified culture identifier.

GetCultureInfo(String) GetCultureInfo(String) GetCultureInfo(String) GetCultureInfo(String)

Retrieves a cached, read-only instance of a culture using the specified culture name.

GetCultureInfo(String, String) GetCultureInfo(String, String) GetCultureInfo(String, String) GetCultureInfo(String, String)

Retrieves a cached, read-only instance of a culture. Parameters specify a culture that is initialized with the TextInfo and CompareInfo objects specified by another culture.

GetCultureInfo(Int32) GetCultureInfo(Int32) GetCultureInfo(Int32) GetCultureInfo(Int32)

Retrieves a cached, read-only instance of a culture by using the specified culture identifier.

public:
 static System::Globalization::CultureInfo ^ GetCultureInfo(int culture);
public static System.Globalization.CultureInfo GetCultureInfo (int culture);
static member GetCultureInfo : int -> System.Globalization.CultureInfo
Public Shared Function GetCultureInfo (culture As Integer) As CultureInfo
Parameters
culture
Int32 Int32 Int32 Int32

A locale identifier (LCID).

Returns
Exceptions

culture specifies a culture that is not supported. See the Notes to Caller section for more information.

Remarks

We recommend that you use the string overload of this method (GetCultureInfo(String)), because locale names should be used instead of LCIDs. For custom locales, the locale name is required.

If culture is the locale identifier of the current culture, the returned CultureInfo object does not reflect any user overrides.

Notes to Callers

The .NET Framework 3.5 and earlier versions throw an ArgumentException if culture is not a valid culture identifier. Starting with the .NET Framework 4, this method throws a CultureNotFoundException. Starting with apps that run under the .NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is culture from the operating system; if the operating system does not support that culture, the method throws a CultureNotFoundException.

See Also

GetCultureInfo(String) GetCultureInfo(String) GetCultureInfo(String) GetCultureInfo(String)

Retrieves a cached, read-only instance of a culture using the specified culture name.

public:
 static System::Globalization::CultureInfo ^ GetCultureInfo(System::String ^ name);
public static System.Globalization.CultureInfo GetCultureInfo (string name);
static member GetCultureInfo : string -> System.Globalization.CultureInfo
Public Shared Function GetCultureInfo (name As String) As CultureInfo
Parameters
name
String String String String

The name of a culture. name is not case-sensitive.

Returns
Exceptions

name specifies a culture that is not supported. See the Notes to Callers section for more information.

Remarks

For a list of predefined culture names, see the National Language Support (NLS) API Reference at the Go Global Developer Center. In addition, starting with Windows 10, name can be any valid BCP-47 language tag.

The GetCultureInfo method retrieves a cached, read-only CultureInfo object. It offers better performance than a corresponding call to the CultureInfo.CultureInfo(String) constructor.

If name is the name of the current culture, the returned CultureInfo object does not reflect any user overrides. This makes the method suitable for server applications or tools that do not have a real user account on the system and that need to load multiple cultures efficiently.

If name is String.Empty, the method returns the invariant culture. This is equivalent to retrieving the value of the InvariantCulture property.

Notes to Callers

The .NET Framework 3.5 and earlier versions throw an ArgumentException if name is not a valid culture name. Starting with the .NET Framework 4, this method throws a CultureNotFoundException. Starting with apps that run under the .NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is name from the operating system; if the operating system does not support that culture, and if name is not the name of a supplementary or replacement culture, the method throws a CultureNotFoundException.

See Also

GetCultureInfo(String, String) GetCultureInfo(String, String) GetCultureInfo(String, String) GetCultureInfo(String, String)

Retrieves a cached, read-only instance of a culture. Parameters specify a culture that is initialized with the TextInfo and CompareInfo objects specified by another culture.

public:
 static System::Globalization::CultureInfo ^ GetCultureInfo(System::String ^ name, System::String ^ altName);
public static System.Globalization.CultureInfo GetCultureInfo (string name, string altName);
static member GetCultureInfo : string * string -> System.Globalization.CultureInfo
Public Shared Function GetCultureInfo (name As String, altName As String) As CultureInfo
Parameters
name
String String String String

The name of a culture. name is not case-sensitive.

altName
String String String String

The name of a culture that supplies the TextInfo and CompareInfo objects used to initialize name. altName is not case-sensitive.

Returns
Exceptions

name or altName specifies a culture that is not supported. See the Notes to Callers section for more information.

Remarks

For a list of predefined culture names, see the National Language Support (NLS) API Reference at the Go Global Developer Center. In addition, starting with Windows 10, name can be any valid BCP-47 language tag.

The GetCultureInfo method obtains a cached, read-only CultureInfo object. It offers better performance than a corresponding call to a CultureInfo constructor. The method is used to create a culture similar to that specified by the name parameter, but with different sorting and casing rules.

If name or altName is the name of the current culture, the returned objects do not reflect any user overrides. If name is String.Empty, the method returns the invariant culture. This is equivalent to retrieving the value of the InvariantCulture property. If altName is String.Empty, the method uses the writing system and comparison rules specified by the invariant culture.

Notes to Callers

The .NET Framework 3.5 and earlier versions throw an ArgumentException if name or altName is not a valid culture name. Starting with the .NET Framework 4, this method throws a CultureNotFoundException. Starting with apps that run under the .NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is name from the operating system; if the operating system does not support that culture, and if name is not the name of a supplementary or replacement culture, the method throws a CultureNotFoundException exception. Starting with apps that run under the .NET Framework 4 or later on Windows 7 or later, the method attempts to retrieve a CultureInfo object whose identifier is name from the operating system; if the operating system does not support that culture, and if name is not the name of a supplementary or replacement culture, the method throws a CultureNotFoundException exception.

See Also

Applies to