效果图:

原理:在所有要丢失精度的小数位中加5,大于10进位

代码:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace Example48

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {

            double P_dbl_value1, P_dbl_value2;

            if (double.TryParse(textBox1.Text, out P_dbl_value1) && 

                double.TryParse(textBox2.Text, out P_dbl_value2))

            {

                textBox3.Text =  Math.Round(P_dbl_value1 + P_dbl_value2, comboBox1.SelectedIndex + 1).ToString();

            }

        }

    }

}

posted on 2011-10-23 13:37  C#_初学者  阅读(271)  评论(0编辑  收藏  举报