Hello
I have a class that I use to format a double value and return it as a string. I have been having a problem with culture settings that use a comma (rather than period) as the decimal separator. I tried the following :
static
{
System.Globalization.CultureInfo.get_CurrentCulture().get_NumberFormat().set_NumberDecimalSeparator(".");
}
which causes an exception to be thrown:
System.InvalidOperationException: Instance is read-only
Is it possible to do Am I trying to take too much of a shorcut
My current workaround involves checking characters from right to left and replacing the first "." I find (numbers are converted to string with decimal first).
Thanks

Change Decimal Separator
captJackSparo
Here is the sample in J#
NumberFormatInfo nfi = new CultureInfo("de-de", false).get_NumberFormat(); double dd = 34234324.3423423423423;nfi.set_NumberDecimalSeparator(
"."); Console.WriteLine(new java.lang.Double(dd).ToString(nfi));nfi.set_NumberDecimalSeparator (
","); Console.WriteLine(new java.lang.Double(dd).ToString(nfi));Paul Dettorre
Try creating a new CultureInfo and then setting the CurrentThread's CurrentCulture to be that culture.
Please vistit msdn to get more on CultureInfo object
Thanks,
LavP
Hi,
NumberDecimalSeparator property in System.Globalization.CultureInfo is readonly. Hence you get the exception.
You can get more information on the link below.
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemglobalizationnumberformatinfoclassnumberdecimalseparatortopic.asp
Thanks,
Varun