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

      <bdo id='TTOkL'></bdo><ul id='TTOkL'></ul>
    <tfoot id='TTOkL'></tfoot>

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

    1. <legend id='TTOkL'><style id='TTOkL'><dir id='TTOkL'><q id='TTOkL'></q></dir></style></legend>
    2. 如何将十进制值显示到小数点后 2 位?

      How do I display a decimal value to 2 decimal places?(如何将十进制值显示到小数点后 2 位?)

      <small id='2Nimo'></small><noframes id='2Nimo'>

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

                本文介绍了如何将十进制值显示到小数点后 2 位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                当前使用 .ToString() 显示小数的值时,精确到小数点后 15 位,因为我用它来表示美元和美分,所以我只想要输出为小数点后 2 位.

                When displaying the value of a decimal currently with .ToString(), it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places.

                我是否为此使用 .ToString() 的变体?

                Do I use a variation of .ToString() for this?

                推荐答案

                decimalVar.ToString("#.##"); // returns ".5" when decimalVar == 0.5m
                

                decimalVar.ToString("0.##"); // returns "0.5"  when decimalVar == 0.5m
                

                decimalVar.ToString("0.00"); // returns "0.50"  when decimalVar == 0.5m
                

                这篇关于如何将十进制值显示到小数点后 2 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                IBM.Data.DB2.Core connection problems(IBM.Data.DB2.Core 连接问题)
                Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                Datetime field overflow with IBM Data Server Client v9.7fp5(IBM Data Server Client v9.7fp5 的日期时间字段溢出)
                Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)
                <legend id='HLjxr'><style id='HLjxr'><dir id='HLjxr'><q id='HLjxr'></q></dir></style></legend>
              • <small id='HLjxr'></small><noframes id='HLjxr'>

                  <bdo id='HLjxr'></bdo><ul id='HLjxr'></ul>
                  <tfoot id='HLjxr'></tfoot>

                      <tbody id='HLjxr'></tbody>

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