Last post Nov 16, 2007 08:08 AM by hemant_vikram
Nov 15, 2007 04:53 AM|hemant_vikram|LINK
In my ASP.NET 2.0 web application, i have 2 cultures used. One is English and the other one is French. I 'm also manipulating an xml file when one of the page is loaded. One of the element of the xml file has a value 0.5. After having changed
the language to french and on doing the parse function, I get invalid cast exception. It works fine with English culture. Give me a suitable way to handle this discripancies.
I have tried the following method and it seems to be working but not sure how far this will help me
double.Parse("0.5", System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture )
Is the above conversion good with ANY CULTURE ?
Nov 15, 2007 05:07 AM|DMW|LINK
The best way to handle this is using the following rules:
1. When presenting data to the user (typically as strings) use the current client culture
2. When parsing input data from the client, use the current client culture
3. When serializing / deserialising data internally within the application, use invariant culture
The first two rules are obvious: the user will expect to see, and input, data according to the rules of their locale. The third rule just makes things simple within the application. Whenever you're saving or loading data, say to/from an XML stream or file,
using invariant culture means that you won't have to worry about which culture was used by the client or server.
Nov 16, 2007 08:08 AM|hemant_vikram|LINK
Thanks man [:)] and s i 'm currently following this techinique of invariant culture and till now working fine. Will let you know more if i encounter anything interesting. Thanx again Dave