11.1 Determining a User s Culture Information

 <  Day Day Up  >  

11.1 Determining a User 's Culture Information

You want to determine culture information based on the current settings of the user's operating system.


Technique

You use the CultureInfo class to retrieve and set the currently executing thread's culture information. The static method CurrentCulture defined within the CultureInfo class creates a CultureInfo object that you can use to retrieve various cultural properties. Some of these properties include the locale Id ( LCID ), calendars used in that culture, International Organization for Standardization (ISO) identifiers, and the name of the culture as displayed in the language of that culture. Figure 11.1 shows the CultureInfo Browser application created as a supplement for this recipe. The property grid within the application contains the various CultureInfo properties for the Farsi culture.

Figure 11.1. The CultureInfo class is the primary class used to retrieve information about a user's current culture settings.

graphics/11fig01.gif

Comments

The CultureInfo class is the first stepping stone into the globalization realm. Whenever your application executes, the Windows API function GetUserDefaultLCID retrieves the locale identifier for the current user. This identifier is then used to create the CultureInfo object that you can retrieve with a call to the static CurrentCulture method. You are then free to access the various properties within this CultureInfo object to effectively display correct information for that culture. Some of the properties that you will most likely access include the NumberFormatInfo object used to correctly display culturally aware numbers and the DateTimeFormat object used for the correct date and time display or manipulation. Recipes later in this chapter demonstrate how to use these objects.

 <  Day Day Up  >  


Microsoft Visual C# .Net 2003
Microsoft Visual C *. NET 2003 development skills Daquan
ISBN: 7508427505
EAN: 2147483647
Year: 2003
Pages: 440

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net