Tweet
|
CultureInfo and RegionInfo class should be created aware of OS setting locale or user specific one, with no hardcoded language and country.
*** These codes are not recommended. CultureInfo myCIintl = new CultureInfo( "es-ES"); <- *created by the hardcoded name CultureInfo myCIintl = new CultureInfo(0x0409); <- *created by the hardcoded LCID RegionInfo myRI1 = new RegionInfo("US"); <- *created by the hardcoded name RegionInfo myRI2 = new RegionInfo(0x0409); <- *created by the hardcoded LCIDLike the other programming language (e.g. Java), you have to care about the functionalities affected by locale (called 'culture' in .NET).
------------------------------------------------------------------------------------------------ Important classes and methods ------------------------------------------------------------------------------------------------ *DateTimeFormatInfo Format date and time *NumberFormatInfo Format numbers and currencies *String.ToUpper/ToLower Make strings uppercase/lowercase *String.Compare/CompareTo/CompareOrdinal Compare the strings *Array.Sort Sort data *DateTime.ToString Format the date and time string with given format character. ("d", "D", "f", "F", ...etc) The culture specific format (e.g. "yyyy/mm/dd") should not be used. The following methods are corresponding to the each format character, but using ToSting is recommended because it can handle more formats. *ToShortDateString *ToLongDateString *ToShortTimeString *ToLongTimeString The following are culture specific classes about calendar. *GregorianCalendar *HebrewCalendar *HijiriCalendar *JapaneseCalendar *JulianCalendar *koreanCalendar *PersianCalendar *TaiwanCalendar *ThaiBuddhistCalendar *ChineseLunisolarCalendar *JapaneseLunisolarCalendar *KoreanLunisolarCalendar *ThaiwanLunisolarCalendar *JalaaliCalendar *UmAlQuraCalendar
You can get the current culture and the current UI-culture in the following steps.
System.Globalization.CultureInfo curCi= System.Globalization.CultureInfo.CurrentCulture; System.Globalization.CultureInfo curUICi= System.Globalization.CultureInfo.CurrentUICulture;CurrentCulture is a culture used by the current thread, and CurrentUICulture is a culture used by ResourceManager to refer to resources when the application is running.
Go to Internationalization Programming Top