I am facing localization issue with my Silverlight application. I am working on one financial application and showing the company reported data on grid. I am trying to implement the localization stuffs, having en-US (English - United States) as default localization, but i want to change the localization to es-AR (Spanish - Argentina) and i am facing the following issue.
My value is 0.21
In en-US it is represented as 0.21 and In es-AR it is represented as 0,21
When my machine localization is es-AR Convert.ToDouble("0.21") is getting converted as 21.0
I have searched on internet and found that i need to pass the culture number format, still having the same issue
double dblValue = Convert.ToDouble("0.21");
// Out Put is 21.00
Thread.CurrentThread.CurrentCulture = new CultureInfo("es-AR");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-AR");
numFormatInfo.NumberDecimalSeparator = ",";
numFormatInfo.NumberGroupSeparator = ".";
double dblValue = Convert.ToDouble("0.21", numFormatInfo);
// Out Put is same again 21.00
Also the following statements throws me error of invalid number format on "es-AR" culture
double dblValue = Convert.ToDouble("86,131,789");
double dblValue = Convert.ToDouble("86,131,789", numFormatInfo);
// Throws Error -
System.FormatException: Input string was not in the correct format.
en System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
en System.Convert.ToDouble(String value)
So how should i achieve this ?