I have code that was originally written for an English language market where the decimal separator is "." so it's expecting numeric values as strings to use "." as the separator. But we now have users in other places, e.g., places in Europe where the decimal separator is ",".
So, in the context of my software (really just the current thread) I want to override the decimal separator for the current language to be "." even if it defaults to something else.
I tried
String sep = ".";
NumberFormatInfo nfi1 = NumberFormatInfo.CurrentInfo;
nfi1.NumberDecimalSeparator = sep;
But I get an "Instance is read-only" exception on the third line. Apparently NumberFormatInfo is not writable. So how DO you set the current language's decimal separator to something other than its default?
Thread.CurrentCulture
to a new instance ofCultureInfo
and make changes to that instance. – Cracow