[Solved] C# basic Math, want to use decimals sometimes


Integers don’t have fractions. Use decimal if you want reliable numeric values with decimals.

decimal box1 = decimal.Parse(Number1TextBox.Text);
decimal box2 = decimal.Parse(Number2TextBox.Text);
decimal box3 = decimal.Parse(Number3TextBox.Text);

decimal answer = box1 * box2 * box3;

You can round back the result like this:

decimal rounded = Math.Round(answer);

5

solved C# basic Math, want to use decimals sometimes