Retrieving culture information

The .NET Compact Framework platform intrinsically handles all date, time, numbers, and string formatting whenever the mobile user changes the current culture of the device. However, there might be cases when your code needs to know the current culture of the device. For example, currency conversion is something the platform does not do for you automatically. You might wish to find out what the default currency of the mobile device is set to and use that to automatically calculate and display its equivalent value in US dollars.

The following code snippet allows you to retrieve the current culture of the mobile device. Using the CultureInfo object, you can query a rich set of information about the language, date/time format, numerical format, and currency of the mobile device.

using System.Globalization;
.
.
.
CultureInfo _culture = CultureInfo.CurrentCulture;
string _summary;
_summary = "Culture: " + _culture.EnglishName + "
";
_summary += "Date: " + _culture.DateTimeFormat.LongDatePattern
+ "
";
_summary += "Lang: " + _culture.ThreeLetterISOLanguageName + "
";
_summary += "Currency: " +
_culture.NumberFormat.CurrencySymbol + "
";
_summary += "Decimal Separator: " +
_culture.NumberFormat.NumberDecimalSeparator + "
";
_summary += "Group separator: " +
_culture.NumberFormat.NumberGroupSeparator + "
";
_summary += "Negative symbol: " +
_culture.NumberFormat.NegativeSign + "
";
MessageBox.Show(_summary);

If you run the previous code snippet, you can see a pop-up message box similar to the one shown as follows:

Retrieving culture information
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.181.89