c# - string.Format "C" (currency) is returning the string "C" instead of formatted text -


I am trying to ensure that the text in my control obtained from the text box is always formatted as currency .

I have overridden text properties like this.

  Public override string text {get {return base.Text; } Set {double tempDollarAmount = 0; String tempVal = value.Replace ("$", ""). Change (",", ""); If (double trepeers (Templewill, out tempDialAmerMount)) {base.Text = string.Format ("C", tempDollarAmount); } And {base.Text = "$ 0.00"; }}  

Result:

  • If I pass the text of the value "text" (AmountControl.Text = "text";), the control < / Li>
  • If I pass value 7 (AmountControl.Text = "7";), I hope to see "$ 7.00", but its text is set to "C" on my test page.

I think I am missing something very simply here. Is there something about the property? Or am I using string format method incorrectly?

instead of "c" "{0: c}"

more string Go to

for formatting issues

Comments