Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CultureInfo.GetCultureInfo Method (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.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

public static CultureInfo GetCultureInfo(
	string name,
	string altName
)

Parameters

name
Type: System.String

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

altName
Type: System.String

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

Return Value

Type: System.Globalization.CultureInfo
A read-only CultureInfo object.

ExceptionCondition
ArgumentNullException

name or altName is null.

CultureNotFoundException

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

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft