Globalization means we need to build application that work anywhere with respective culture of particular region. It should show region specific date time format, currency symbol, language etc.
Thanks to .net framework, they have provided System.Threading and System.Globalization namespaces to build application that supports Globalization.
As we know different countries have their own language and have their own data format facility. Say for example some countries use comma separator for decimal some use period. If we have hard coded application that certainly it will not work in different culture than we have built.
Culture is always specified in computer when application run on it, it takes culture from computer previously set culture. We can override this culture but it can be only for application. To set culture we can use below syntax.
Thread.CurrentThread.CurrentCulture = new CultureInfo("es-ES");
Here we have provided culture information by “en-ES”. There are different types of culture are available like specific culture, natural culture. Specific culture gives all of the data format facility for that culture while in case of natural culture we get only language specific transformation.
By providing culture setting we can also change its date,time format or even we can change currency format by accessing various property of date time and data format classes of NumberFormat and NumberDecimalSeparator.
One care should be taken when we use globalization in sorting and comparison, because in different culture they have different priority of letters and symbol priority.
At that time we can have two options either use StringCompariosn.InvarianCulture or use below syntax.
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture
No comments:
Post a Comment