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

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

      <tfoot id='ucFnS'></tfoot>

        在 C# 中使用自定义千位分隔符

        Use a custom thousand separator in C#(在 C# 中使用自定义千位分隔符)
            • <bdo id='m0QNj'></bdo><ul id='m0QNj'></ul>
                <tbody id='m0QNj'></tbody>

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

                • <small id='m0QNj'></small><noframes id='m0QNj'>

                  本文介绍了在 C# 中使用自定义千位分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我试图在显示字符串时不使用,"字符作为千位分隔符,而是使用空格.我想我需要定义一种自定义文化,但我似乎没有做对.有什么指点吗?

                  I'm trying not to use the ',' char as a thousand separator when displaying a string, but to use a space instead. I guess I need to define a custom culture, but I don't seem to get it right. Any pointers?

                  例如:将 1000000 显示为 1 000 000 而不是 1,000,000

                  eg: display 1000000 as 1 000 000 instead of 1,000,000

                  (不,String.Replace() 不是我想使用的解决方案:P)

                  (no, String.Replace() is not the solution I'd like to use :P)

                  推荐答案

                  建议你找一个NumberFormatInfo 最接近你想要的(即它与千位分隔符分开),调用 Clone() 就可以了,然后设置 NumberGroupSeparator 属性.(如果您要使用货币格式格式化数字,您需要更改 CurrencyGroupSeparator 代替/以及.)将其用作调用 string.Format 等的格式信息,你应该没问题.例如:

                  I suggest you find a NumberFormatInfo which most closely matches what you want (i.e. it's right apart from the thousands separator), call Clone() on it and then set the NumberGroupSeparator property. (If you're going to format the numbers using currency formats, you need to change CurrencyGroupSeparator instead/as well.) Use that as the format info for your calls to string.Format etc, and you should be fine. For example:

                  using System;
                  using System.Globalization;
                  
                  class Test
                  {
                      static void Main()
                      {
                          NumberFormatInfo nfi = (NumberFormatInfo)
                              CultureInfo.InvariantCulture.NumberFormat.Clone();
                          nfi.NumberGroupSeparator = " ";
                  
                          Console.WriteLine(12345.ToString("n", nfi)); // 12 345.00
                      }
                  }
                  

                  这篇关于在 C# 中使用自定义千位分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                    <legend id='1eEAP'><style id='1eEAP'><dir id='1eEAP'><q id='1eEAP'></q></dir></style></legend>

                    <i id='1eEAP'><tr id='1eEAP'><dt id='1eEAP'><q id='1eEAP'><span id='1eEAP'><b id='1eEAP'><form id='1eEAP'><ins id='1eEAP'></ins><ul id='1eEAP'></ul><sub id='1eEAP'></sub></form><legend id='1eEAP'></legend><bdo id='1eEAP'><pre id='1eEAP'><center id='1eEAP'></center></pre></bdo></b><th id='1eEAP'></th></span></q></dt></tr></i><div id='1eEAP'><tfoot id='1eEAP'></tfoot><dl id='1eEAP'><fieldset id='1eEAP'></fieldset></dl></div>
                      <tbody id='1eEAP'></tbody>
                  1. <small id='1eEAP'></small><noframes id='1eEAP'>

                          <bdo id='1eEAP'></bdo><ul id='1eEAP'></ul>

                            <tfoot id='1eEAP'></tfoot>