2017-01-26 8 views
0

力をlbs単位で強制的にニュートンに変換するコードを作成しています。私は正しく変換するためのすべてを持っていますが、なぜMath.Roundメソッドが動作していないのか分からないようです。3小数点以下四捨五入 - Visual Studio

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; 

私は間違っていると思いますか?

答えて

2

Math.Roundは値を変更しません。代わりに新しいものを返します。

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

ありがとうございます!それは完璧に働いた。 – Tarheel81

関連する問題