-3

I found a ton of answers but none work for me, can anyone help me with this problem. I have a formula witch gives a very extensive result and only want a value like for instance 1,25

I tried several codes but none worked, what i have now is:

    uw = (adp * ufa + adv * ug + perv * wmk) / ac;
    String.Format("{0:.##}", uw);
    resposta.Text = uw.ToString();

resposta is a label in witch i display the answer. uw is decimal.

I dont want to round the value, just limit the numbers.

Thansk for the assist,

MarcIT
  • 39
  • 11

1 Answers1

2

This should work if you are OK with rounding:

uw = (adp * ufa + adv * ug + perv * wmk) / ac;
resposta.Text = uw.ToString("N2");

This should work if you don't want to round values:

uw = (adp * ufa + adv * ug + perv * wmk) / ac;
resposta.Text = (Math.Truncate(uw * 100) / 100).ToString();
Kaspars Ozols
  • 6,967
  • 1
  • 20
  • 33