In this article we will explore various outputs of RegionInfo and CultureInfo. RegionInfo represents the current country/region used by the thread. CultureInfo provides information about specific culture in Windows Phone 7.
Properties of System.Globalization.RegionInfo.CurrentRegion and the output of the propery if Country/Region is set as United States.
System.Globalization.RegionInfo.CurrentRegion.CurrencySymbol provides currency symbol associated with that country/region. Output: $
System.Globalization.RegionInfo.CurrentRegion.DisplayName provides the full name of country/region in the localized language of .NET framework. Output: United States
System.Globalization.RegionInfo.CurrentRegion.EnglishName provides the full name of country/region in english. Output: United States
System.Globalization.RegionInfo.CurrentRegion.IsMetric returns the boolean value based on the country/region uses metric system of measurement. Output: False
System.Globalization.RegionInfo.CurrentRegion.ISOCurrencySymbol provides three characte ISO 4217 currency symbol of the country/region. Output: USD
System.Globalization.RegionInfo.CurrentRegion.Name provides the name or ISO 3166 two letter country/region code. Output: US
System.Globalization.RegionInfo.CurrentRegion.NativeName provides the name of a country/region formatted in native language. Output: United States
System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName provides two letter code defined in ISO 3166 for that county/region. Output: US
Properties of System.Globalization.CultureInfo.CurrentCulture and the output of the propery if Country/Region is set as United States.
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern gets or sets the custom format string of long date value. Output: dddd, MMMM dd, yyyy
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern gets or sets the custom format string of short date value. Output: M/d/yyyy
System.Globalization.CultureInfo.CurrentCulture.DisplayName provides culture name in the format "language country/region" in the localized version of .NET framework. Output: English (United States)
System.Globalization.CultureInfo.CurrentCulture.EnglishName provides culture name in the format "language country/region" in english. Output: English (United States)
System.Globalization.CultureInfo.CurrentCulture.Name provides the culture name in the format of "languagecode-country/regioncode" Output: en-US
System.Globalization.CultureInfo.CurrentCulture.NativeName provides language, country/region and optional script that culture is set to display. Output: English (United States)
System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName provides ISO 639-1 two letter code for the language. Output: en
Let's write small snippet of code to demonstrate RegionInfo.CurrentRegion and CultureInfo.CurrentCulture in Windows Phone 7
Step 1: Create a Windows Phone 7 project and add below textblocks inside contentpanel grid of MainPage.Xaml
< Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,20,0,0" Name="currencySymbol" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,60,0,0" Name="displayName" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,100,0,0" Name="englishName" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,140,0,0" Name="isMetric" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,180,0,0" Name="isoCurrency" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,220,0,0" Name="name" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,260,0,0" Name="nativeName" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,300,0,0" Name="twoLetterISORegionName" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,340,0,0" Name="displayTimeFormatLP" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,380,0,0" Name="displayName1" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,420,0,0" Name="englishName1" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,460,0,0" Name="name1" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,500,0,0" Name="nativeName1" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,540,0,0" Name="numberFormat" VerticalAlignment="Top" FontSize="18" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="10,580,0,0" Name="displayTimeFormatSP" VerticalAlignment="Top" FontSize="18" /> </Grid>
Step 2: Now we will access propties of RegionInfo.CurrentRegion and CultureInfo.CurrentCulture and assign it to TextBlock.
public MainPage() { InitializeComponent(); currencySymbol.Text = "Regional Info of CurrencySymbol: " + System.Globalization.RegionInfo.CurrentRegion.CurrencySymbol; displayName.Text = "Regional Info of DisplayName: " + System.Globalization.RegionInfo.CurrentRegion.DisplayName; englishName.Text = "Regional Info of EnglishName: " + System.Globalization.RegionInfo.CurrentRegion.EnglishName; isMetric.Text = "Regional Info of IsMetric: " + System.Globalization.RegionInfo.CurrentRegion.IsMetric.ToString(); isoCurrency.Text = "Regional Info of ISOCurrencySymbol: " + System.Globalization.RegionInfo.CurrentRegion.ISOCurrencySymbol; name.Text = "Regional Info of CurrentRegion: " + System.Globalization.RegionInfo.CurrentRegion.Name; nativeName.Text = "Regional Info of NativeName: " + System.Globalization.RegionInfo.CurrentRegion.NativeName; twoLetterISORegionName.Text = "Regional Info of TwoLetterISORegionName: " + System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName;
displayTimeFormatLP.Text = "Culture Info of LongDatePattern: " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern.ToString(); displayTimeFormatSP.Text = "Culture Info of ShortDatePattern: " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToString(); displayName1.Text = "Culture Info of DisplayName: " + System.Globalization.CultureInfo.CurrentCulture.DisplayName; englishName1.Text = "Culture Info of EnglishName: " + System.Globalization.CultureInfo.CurrentCulture.EnglishName; name1.Text = "Culture Info of Name: " + System.Globalization.CultureInfo.CurrentCulture.Name; nativeName1.Text = "Culture Info of NativeName: " + System.Globalization.CultureInfo.CurrentCulture.NativeName; numberFormat.Text = "Culture Info of TwoLetterISOLanguageName: " + System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName; }
Now run the application, the output will be like show below.

This ends the article of culture information in Windows Phone 7.
|