Culture info walkthrough

Jul 4 2012 4:10 AM

Provides information about a specific culture (called a "locale" for unmanaged code development). The information includes the names for the culture, the writing system, the calendar used, and formatting for dates and sort strings.

The CultureInfo class renders culture-specific information, such as the associated language, sublanguage, country/region, calendar, and cultural conventions. This class also provides access to culture-specific instances of DateTimeFormatInfo, NumberFormatInfo, CompareInfo, and TextInfo. These objects contain the information required for culture-specific operations, such as casing, formatting dates and numbers, and comparing strings.

The String class indirectly uses this class to obtain information about the default culture.


public static List<Language> GetCultures()

        {

            List<Language> lstLocales = new List<Language>();

            foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))

            {

                Language obj = new Language();

                obj.LanguageCode = ci.Name;

                obj.LanguageName = ci.EnglishName;

                lstLocales.Add(obj);

            }

            return lstLocales;

        }