0

Can someone please help me by reviewing why the label on visual studio is not displaying currency? Any help is appreciated.

double hours = Convert.ToDouble(textBox1.Text);
double rate = Convert.ToDouble(textBox2.Text);
double grosspay = hours * rate;

string.Format("{0:c}", label9.Text);
label9.Text = grosspay.ToString();
Adam Modlin
  • 2,994
  • 2
  • 22
  • 39
user3280557
  • 1
  • 1
  • 1

1 Answers1

2

I suppose that you want to assign the result of string.Format to your label text

label9.Text = string.Format("{0:C}", grosspay)

But working with currency values is usually done using the decimal datatype

decimal hours = Convert.ToDecimal(textBox1.Text);
decimal rate = Convert.ToDecimal(textBox2.Text);
decimal grosspay = hours * rate;
label9.Text = string.Format("{0:C}", grosspay)

When should I use double instead of decimals?

Community
  • 1
  • 1
Steve
  • 213,761
  • 22
  • 232
  • 286