久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

      2. <tfoot id='BdUqu'></tfoot>
      3. <legend id='BdUqu'><style id='BdUqu'><dir id='BdUqu'><q id='BdUqu'></q></dir></style></legend>
          <bdo id='BdUqu'></bdo><ul id='BdUqu'></ul>

        十進制字符串與千位分隔符?

        Decimal to string with thousand#39;s separators?(十進制字符串與千位分隔符?)

            • <bdo id='bF3xR'></bdo><ul id='bF3xR'></ul>

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

                    <tbody id='bF3xR'></tbody>
                1. <tfoot id='bF3xR'></tfoot>

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

                  本文介紹了十進制字符串與千位分隔符?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  考慮一個十進制值:

                  Decimal value = -1234567890.1234789012M;
                  

                  我想將此十進制 值轉換為字符串,并包含千位分隔符".

                  i want to convert this Decimal value to a string, and include "thousands separators".

                  注意:我不想包含千位分隔符,我想包含數字分組.對于不將數字分組為數千或不使用逗號分隔組的文化,這種差異很重要

                  Note: i don't want to include thousand's separators, i want to include digit grouping. The difference is important for cultures that don't group numbers into thousands, or don't use commas to separate groups

                  在我的計算機上使用我當前的語言環境使用不同標準格式字符串的一些示例輸出:

                  Some example output with different standard formatting strings, on my computer, with my current locale:

                  value.ToString()        =  -1234567890..1234789012   (Implicit General)
                  value.ToString("g")     =  -1234567890..1234789012   (General)
                  value.ToString("d")     =          FormatException   (Decimal whole number)
                  value.ToString("e")     =         -1..234568e++009   (Scientific)
                  value.ToString("f")     =         -1234567890..123   (Fixed Point)
                  value.ToString("n")     =     -12,,3456,,7890..123   (Number with commas for thousands)
                  value.ToString("r")     =          FormatException   (Round trippable)
                  value.ToString("c")     =   -$$12,,3456,,7890..123   (Currency)
                  value.ToString("#,0.#") =     -12,,3456,,7890..1
                  

                  想要(取決于文化)是:

                  en-US      -1,234,567,890.1234789012
                  ca-ES      -1.234.567.890,1234789012
                  gsw-FR     -1 234 567 890,1234789012    (12/1/2012: fixed gws-FR to gsw-FR)
                  fr-CH      -1'234'567'890.1234789012
                  ar-DZ       1,234,567,890.1234789012-
                  prs-AF      1.234.567.890,1234789012-
                  ps-AF       1?234?567?890,1234789012-
                  as-IN     -1,23,45,67,890.1234789012
                  lo-LA      (1234567,890.1234789012)     (some debate if numbers should be "1,234,567,890")
                  qps-PLOC  12,,3456,,7890..1234789012
                  

                  如何將 Decimal 轉換為帶有數字分組的字符串?

                  How can i convert a Decimal to a string, with digit groupings?

                  更新:更多期望輸出,使用我目前的文化:

                  Update: Some more desired output, using my current culture of :

                  -1234567890M             -->   -12,,3456,,7890
                  -1234567890.1M           -->   -12,,3456,,7890..1
                  -1234567890.12M          -->   -12,,3456,,7890..12
                  -1234567890.123M         -->   -12,,3456,,7890..123
                  -1234567890.1234M        -->   -12,,3456,,7890..1234
                  -1234567890.12347M       -->   -12,,3456,,7890..12347
                  -1234567890.123478M      -->   -12,,3456,,7890..123478
                  -1234567890.1234789M     -->   -12,,3456,,7890..1234789
                  -1234567890.12347890M    -->   -12,,3456,,7890..1234789
                  -1234567890.123478901M   -->   -12,,3456,,7890..123478901
                  -1234567890.1234789012M  -->   -12,,3456,,7890..1234789012
                  

                  <小時>

                  更新:我嘗試查看 Decimal.ToString() 如何設法使用 General 格式來顯示它需要的所有數字顯示:


                  Update: i tried peeking at how Decimal.ToString() manages to use the General format to show all the digits that it needs to show:

                  public override string ToString()
                  {
                      return Number.FormatDecimal(this, null, NumberFormatInfo.CurrentInfo);
                  }
                  

                  除了 Number.FormatDecimal 隱藏在某處:

                  [MethodImpl(MethodImplOptions.InternalCall)]
                  public static extern string FormatDecimal(decimal value, string format, NumberFormatInfo info);
                  

                  所以這是一條死胡同.

                  推薦答案

                  您可以指定自定義模式(該模式將適當地解析為特定于文化的分組方法以及適當的分組和小數分隔符).一個模式可以有正、負和零部分.積極模式始終相同,但消極模式取決于文化,可以從 NumberFormatInfo 的 NumberNegativePattern 屬性.由于您希望盡可能地精確,因此需要在小數點后填寫 28 位占位符;逗號強制分組.

                  You can specify a custom pattern (the pattern will appropriately resolve to the culture specific method of grouping and the appropriate grouping and decimal separator characters). A pattern can have positive, negative and zero sections. The positive pattern is always the same but the negative pattern depends on the culture and can be retrieved from the NumberFormatInfo's NumberNegativePattern property. Since you want as much precision as possible, you need to fill out 28 digit placeholders after the decimal; the comma forces grouping.

                      public static class DecimalFormatters
                      {
                          public static string ToStringNoTruncation(this Decimal n, IFormatProvider format)
                          {
                              NumberFormatInfo nfi = NumberFormatInfo.GetInstance(format);
                              string[] numberNegativePatterns = {
                                      "(#,0.############################)", //0:  (n)
                                      "-#,0.############################",  //1:  -n
                                      "- #,0.############################", //2:  - n
                                      "#,0.############################-",  //3:  n-
                                      "#,0.############################ -"};//4:  n -
                              var pattern = "#,0.############################;" + numberNegativePatterns[nfi.NumberNegativePattern];
                              return n.ToString(pattern, format);
                          }
                  
                          public static string ToStringNoTruncation(this Decimal n)
                          {
                              return n.ToStringNoTruncation(CultureInfo.CurrentCulture);
                          }
                      }
                  

                  樣本輸出

                  Locale    Output
                  ========  ============================
                  en-US     -1,234,567,890.1234789012
                  ca-ES     -1.234.567.890,1234789012
                  hr-HR     - 1.234.567.890,1234789012
                  gsw-FR    -1?234?567?890,1234789012
                  fr-CH     -1'234'567'890.1234789012
                  ar-DZ     1,234,567,890.1234789012-
                  prs-AF    1.234.567.890,1234789012-
                  ps-AF     1?234?567?890,1234789012-
                  as-IN     -1,23,45,67,890.1234789012
                  lo-LA     (1234567,890.1234789012)
                  qps-PLOC  -12,,3456,,7890..1234789012
                  

                  目前沒有使用 NegativeNumberFormat 4 (n -) 的語言環境,因此無法測試這種情況.但沒有理由認為它會失敗.

                  There is currently no locale that uses NegativeNumberFormat 4 (n -), so that case cannot be tested. But there's no reason to think it would fail.

                  這篇關于十進制字符串與千位分隔符?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯誤的 XML)
                2. <tfoot id='9dBMg'></tfoot>
                      <bdo id='9dBMg'></bdo><ul id='9dBMg'></ul>
                        <tbody id='9dBMg'></tbody>

                          <legend id='9dBMg'><style id='9dBMg'><dir id='9dBMg'><q id='9dBMg'></q></dir></style></legend>

                          <small id='9dBMg'></small><noframes id='9dBMg'>

                          • <i id='9dBMg'><tr id='9dBMg'><dt id='9dBMg'><q id='9dBMg'><span id='9dBMg'><b id='9dBMg'><form id='9dBMg'><ins id='9dBMg'></ins><ul id='9dBMg'></ul><sub id='9dBMg'></sub></form><legend id='9dBMg'></legend><bdo id='9dBMg'><pre id='9dBMg'><center id='9dBMg'></center></pre></bdo></b><th id='9dBMg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9dBMg'><tfoot id='9dBMg'></tfoot><dl id='9dBMg'><fieldset id='9dBMg'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 精品久久久久久久人人人人传媒 | 日韩av一区二区在线观看 | 欧美色性 | 成人网在线| 黄色片视频免费 | 日韩www | 日本高清中文字幕 | 成人性视频免费网站 | 日本国产一区二区 | 国产美女在线精品免费 | 亚洲一区二区在线 | 国产精品区一区二区三 | 伊人一区 | 在线看91 | 国产成人久久av免费高清密臂 | 四虎av电影 | 青青草社区| 精品96久久久久久中文字幕无 | 国产精品久久久久久久久久久免费看 | 久久综合伊人 | 精品久久一区 | 91影院| 99热首页 | 成人久久18免费网站 | 亚洲一区二区中文字幕在线观看 | 福利视频三区 | 狠狠操狠狠干 | 一区久久| 久久免费看| 中文字幕亚洲视频 | 日本黄色片免费在线观看 | 婷婷丁香在线视频 | 亚洲激情一区二区三区 | 日韩免费 | 午夜视频在线观看视频 | 91最新视频 | 欧美成人一区二区 | 精品一区二区三区在线观看 | 日韩精品久久久 | 精品国产一级 | 成人免费精品 |