Web页面上    两个输入框TextBox1和TextBox2
一个标签Label1
一个按钮TextBox1输入一个数字(总量)
TextBox2输入一个数字(分量)点击按钮   TextBox1除以TextBox2  结果显示在Label1偶的问题是:当结果除不尽的时候   显示出来的Label1太难看 比如:TextBox1:1.57   TextBox2:6    1.57/6 = 0.261666666666666666666666显示这么多6干吗呀?  取个几位也就够了Waiting online~~~~

解决方案 »

  1.   

    是够easy吧   呵~~~~~~~~~~我都觉得是可是8知道怎么办才好
      

  2.   

    (你的计算结果).substring(0,N) N=你想要几位就几位
      

  3.   

    int i=1;
     int b=6;
     float s= (i/b);
      string str=s.tostring("0.00") ;
      

  4.   

    (你的计算结果).toString().substring(0,N) n=你想要几位就几位
      

  5.   

    描述
    返回按指定位数进行四舍五入的数值。
    语法
    Round(expression[, numdecimalplaces])
    Round 函数的语法有以下参数:参数 描述 
    expression 必选。 数值表达式 被四舍五入。 
    numdecimalplaces 可选。数字表明小数点右边有多少位进行四舍五入。如果省略,则 Round 函数返回整数。
      

  6.   

    Math.Round 方法 (Double)  返回最接近指定值的整数。
    [C#] public static decimal Round(decimal, int); 返回具有指定精度、最接近指定值的数。
    [C#] public static double Round(double, int);返回具有指定精度、最接近指定值的数。
      

  7.   

    double a = 1.57,b = 6,c = 0;
    c = a/b;
    Response.Write(c.ToString("0.00"));
      

  8.   

    呵~~~~~~~~~~~~~明白了   感觉 powerllr(笨笨鸡) 的方法最好   谢谢各位的热心指点~~