Culture Information

The CultureInfo class provides culture-specific information and operations, such as printing dates and sorting strings. You create a CultureInfo object by specifying one of the many predefined culture identifiers as an argument, for example:

' Create a CultureInfo object for the "English-United Kingdom" culture

Dim ci As New CultureInfo("en-GB")

' Create a CultureInfo object for the Qltalian-ItalyE culture Dim ci As New CultureInfo("it-IT")

The culture identifiers—of which there are more than 200—are specified either as hexadecimal values or as strings consisting of the language as a two-letter lowercase identifier plus an optional country/region as an uppercase two-digit identifier. This format lets you distinguish, for instance, between UK English ("en-GB") and US English ("en-US").

Once you've obtained a CultureInfo object, you can use its properties and methods to find out about the culture. Some commonly used properties of the CultureInfo class are summarized in Table 12.5.

Table 12.5: Hi ppM Uk

Property

Description

Calendar

Gets the default calendar used by the culture.

CompareInfo

Gets a CompareInfo object that defines how to compare and sort strings.

DateTimeFormat

Gets a DateTimeFormat object that defines how to format dates and times.

DisplayName

Gets the culture name in the form "language

Table 12.5: Common piprti Mill

Property

Description

(country/region)"; for example, "English (United Kingdom)".

EnglishName

Gets the same result as DisplayName.

NativeName

Gets the culture name in the culture's own language. May not display correctly on English systems.

NumberFormat

Gets a NumberFormatlnfo object that defines how to format numbers, including currencies.

Textlnfo

Gets a Textlnfo object that defines how to format text.

0 0

Post a comment