.net 两个数相除计算百分比 , 保留两位小数

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/yuanwei90315/article/details/8803062

            string signal = "5";             decimal value = Convert.ToDecimal(signal) / 31;             //小数据取两位             int result = (int)(Math.Round(value, 2) * 100);             this.lbSingle.Text = result + "%";

                        decimal d = (decimal)(7) / 6;
                        value= Math.Round(d, 2).ToString();
 
 第二种:
CountNum = 0.0;
LeangTimeCount += int.Parse(dsStudy.Tables[0].Rows[j]["StudyearnedTmie"].ToString());
 
 if (LeangTimeCount == Count)
                        {
                            CountNum = 1;
                        }
                        else
                        {
                            CountNum = (LeangTimeCount / Count) * 100;
                        }
CountNum.ToString("#0.#0") + "%";
展开阅读全文

没有更多推荐了,返回首页