简体   繁体   中英

Rounding to 3 Decimal Places - Visual Studio

I am creating a code to convert force in lbs to force in newtons. I got everything to convert correctly, but can't seem to figure out why the Math.Round method isn't working.

    btnConvert.Enabled = true;



        double pound;
        double force;
        double conversationRate;

        double.TryParse(txtForce.Text, out pound);


        conversationRate = 4.44822;

        force = pound * conversationRate;
        Math.Round(force, 3);

        txtForceN.Text = force.ToString();
        Math.Round(force, 3);

        btnConvert.Enabled = false;

Any idea what I'm doing wrong?

Math.Round does not alter the value. It returns a new one instead.

var newVal = Math.Round(oldVal, 3);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM