List the defined locales in C#


This example is fairly straightforward. When the form loads, the following event handler lists the defined locales.

private void Form1_Load(object sender, EventArgs e)
    // Make the ListBox use tabs.
    lstLocales.UseTabStops = true;
    lstLocales.UseCustomTabOffsets = true;

    // Define the tabs.
    ListBox.IntegerCollection offsets =

    // Add the locale information.
    foreach (CultureInfo info in
            info.EnglishName + '\t' +

    // Display the number of locales.
    lblNumLocales.Text = lstLocales.Items.Count.ToString() +
        " locales";

The code prepares the ListBox to use tab stops. It then loops through the CultureInfo objects returned by CultureInfo.GetCultures(CultureTypes.AllCultures). For each CultureInfo object, the program adds the object’s English and native names separated by a tab to the ListBox. It finishes by displaying the number of locales.

Download Example   Follow me on Twitter   RSS feed

This entry was posted in internationalization, system and tagged , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.