<small id='o1MPb'></small><noframes id='o1MPb'>

      <i id='o1MPb'><tr id='o1MPb'><dt id='o1MPb'><q id='o1MPb'><span id='o1MPb'><b id='o1MPb'><form id='o1MPb'><ins id='o1MPb'></ins><ul id='o1MPb'></ul><sub id='o1MPb'></sub></form><legend id='o1MPb'></legend><bdo id='o1MPb'><pre id='o1MPb'><center id='o1MPb'></center></pre></bdo></b><th id='o1MPb'></th></span></q></dt></tr></i><div id='o1MPb'><tfoot id='o1MPb'></tfoot><dl id='o1MPb'><fieldset id='o1MPb'></fieldset></dl></div>
      • <bdo id='o1MPb'></bdo><ul id='o1MPb'></ul>
    1. <legend id='o1MPb'><style id='o1MPb'><dir id='o1MPb'><q id='o1MPb'></q></dir></style></legend>

      <tfoot id='o1MPb'></tfoot>
      1. 尝试为当前语言设置小数点分隔符,得到“Inst

        时间:2023-08-25
        <i id='TreN9'><tr id='TreN9'><dt id='TreN9'><q id='TreN9'><span id='TreN9'><b id='TreN9'><form id='TreN9'><ins id='TreN9'></ins><ul id='TreN9'></ul><sub id='TreN9'></sub></form><legend id='TreN9'></legend><bdo id='TreN9'><pre id='TreN9'><center id='TreN9'></center></pre></bdo></b><th id='TreN9'></th></span></q></dt></tr></i><div id='TreN9'><tfoot id='TreN9'></tfoot><dl id='TreN9'><fieldset id='TreN9'></fieldset></dl></div>

          <tbody id='TreN9'></tbody>

        <small id='TreN9'></small><noframes id='TreN9'>

        <legend id='TreN9'><style id='TreN9'><dir id='TreN9'><q id='TreN9'></q></dir></style></legend>

            • <bdo id='TreN9'></bdo><ul id='TreN9'></ul>
                <tfoot id='TreN9'></tfoot>
                1. 本文介绍了尝试为当前语言设置小数点分隔符,得到“Instance is read Only";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的代码最初是为英语市场编写的,其中小数点分隔符是."所以它期望数值作为字符串使用."作为分隔符.但是我们现在在其他地方也有用户,例如欧洲的小数点分隔符是,"的地方.

                  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.

                  我试过了

                    String sep = "."; 
                    NumberFormatInfo nfi1 = NumberFormatInfo.CurrentInfo;
                    nfi1.NumberDecimalSeparator = sep;
                  

                  但我在第三行收到Instance is read-only"异常.显然 NumberFormatInfo 是不可写的.那么如何将当前语言的小数点分隔符设置为默认值以外的值呢?

                  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?

                  推荐答案

                  您需要创建一个新的文化,您可以使用当前文化作为模板,只需更改分隔符.然后,您必须将当前文化设置为新创建的文化,因为您无法直接更改当前文化中的属性.

                  You need to create a new culture and you can use the current culture as a template and only change the separator. Then you must set the current culture to your newly created one as you cannot change the property within current culture directly.

                  string CultureName = Thread.CurrentThread.CurrentCulture.Name;
                  CultureInfo ci = new CultureInfo(CultureName);
                  if (ci.NumberFormat.NumberDecimalSeparator != ".")
                  {
                      // Forcing use of decimal separator for numerical values
                      ci.NumberFormat.NumberDecimalSeparator = ".";
                      Thread.CurrentThread.CurrentCulture = ci;
                   }
                  

                  这篇关于尝试为当前语言设置小数点分隔符,得到“Instance is read Only";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Javascript 日期本地化 下一篇:获取本地化路径的功能?

                  相关文章

                  最新文章

                2. <i id='6rRE2'><tr id='6rRE2'><dt id='6rRE2'><q id='6rRE2'><span id='6rRE2'><b id='6rRE2'><form id='6rRE2'><ins id='6rRE2'></ins><ul id='6rRE2'></ul><sub id='6rRE2'></sub></form><legend id='6rRE2'></legend><bdo id='6rRE2'><pre id='6rRE2'><center id='6rRE2'></center></pre></bdo></b><th id='6rRE2'></th></span></q></dt></tr></i><div id='6rRE2'><tfoot id='6rRE2'></tfoot><dl id='6rRE2'><fieldset id='6rRE2'></fieldset></dl></div>

                      <bdo id='6rRE2'></bdo><ul id='6rRE2'></ul>

                    <small id='6rRE2'></small><noframes id='6rRE2'>

                  1. <tfoot id='6rRE2'></tfoot>
                  2. <legend id='6rRE2'><style id='6rRE2'><dir id='6rRE2'><q id='6rRE2'></q></dir></style></legend>