C# 计算百分比

https://www.cnblogs.com/enych/p/10298396.html

复制代码
            //计算比率
            decimal A =(decimal) 200.20; 
            decimal B = (decimal)1000.20; 
        </span><span style="color: rgba(0, 0, 255, 1)">decimal</span> t = <span style="color: rgba(0, 0, 255, 1)">decimal</span>.Parse((A/B).ToString(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">0.000</span><span style="color: rgba(128, 0, 0, 1)">"</span>)) ; <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">保留3位小数
        </span><span style="color: rgba(0, 128, 0, 1)">//

var t1 = Math.Round(t, 2); //四舍五入,精确2位

        <span style="color: rgba(0, 0, 255, 1)">var</span> t2 = t1 * <span style="color: rgba(128, 0, 128, 1)">100</span>;  <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">乘以100     x100结果%</span></pre>
复制代码
      var t3 = Math.Floor(Math.Round(decimal.Parse((0 / 100).ToString("0.000")), 2) * 100);
原文地址:https://www.cnblogs.com/sunny3158/p/14305151.html