久久久久久久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>

        十進(jìn)制字符串與千位分隔符?

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

            • <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'>

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

                  問題描述

                  考慮一個(gè)十進(jìn)制值:

                  Decimal value = -1234567890.1234789012M;
                  

                  我想將此十進(jìn)制 值轉(zhuǎn)換為字符串,并包含千位分隔符".

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

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

                  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

                  在我的計(jì)算機(jī)上使用我當(dāng)前的語言環(huán)境使用不同標(biāo)準(zhǔn)格式字符串的一些示例輸出:

                  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 轉(zhuǎn)換為帶有數(shù)字分組的字符串?

                  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
                  

                  <小時(shí)>

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


                  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);
                  

                  所以這是一條死胡同.

                  推薦答案

                  您可以指定自定義模式(該模式將適當(dāng)?shù)亟馕鰹樘囟ㄓ谖幕姆纸M方法以及適當(dāng)?shù)姆纸M和小數(shù)分隔符).一個(gè)模式可以有正、負(fù)和零部分.積極模式始終相同,但消極模式取決于文化,可以從 NumberFormatInfo 的 NumberNegativePattern 屬性.由于您希望盡可能地精確,因此需要在小數(shù)點(diǎn)后填寫 28 位占位符;逗號(hào)強(qiáng)制分組.

                  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 -) 的語言環(huán)境,因此無法測(cè)試這種情況.但沒有理由認(rèn)為它會(huì)失敗.

                  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.

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

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

                  相關(guān)文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時(shí)忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標(biāo)簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯(cuò)誤的 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>
                          • 主站蜘蛛池模板: a久久| 欧美日韩在线免费观看 | 精品国产1区2区3区 在线国产视频 | 黄色片在线免费看 | www.狠狠干 | 一级黄色网页 | 久久综合九九 | 国产一区日韩在线 | 亚洲精品国产区 | 国产日屁| 一道本视频| 国产精品一卡 | 欧美xxxx网站 | 国产欧美日韩综合精品一 | 国产精品不卡一区 | 成人午夜激情 | 成人av高清在线观看 | 国产亚洲成av人片在线观看桃 | 亚洲精品乱码久久久久v最新版 | 国产aa| 亚洲一区 中文字幕 | 皇色视频在线 | 欧美日韩中文在线 | 国产成人精品一区二区三区四区 | 在线欧美一区 | 久久免费视频1 | 中国美女av | 久久久久久亚洲精品不卡 | 天天插天天操 | 久久亚洲一区二区三区四区 | 久久久精品网站 | av国产精品 | 日本在线综合 | 国产一级在线 | 久久亚洲精品国产精品紫薇 | 欧美黄色性生活视频 | 国产一区二区视频在线观看 | 五月天激情电影 | 午夜精品久久久久久久久久久久 | 男女污污网站 | 久久精品国产久精国产 |