asp.net - C# sometimes currency format does not work -
It looks like sometimes the currency format does not work:
string amount = "11123.45"; Literal2.Text = string.Format ("{0: c}", zodiac);
This code will never work - because the amount is a string, there is no number. The currency format is only applicable to number . For example:
decimal amount = 11123.45m; Console.lightline (string format ("{0: c}", volume);
(Note that using dual for currencies is almost always a bad The idea is, as it can not represent double equal decimal numbers, there is a more appropriate type of decimal financial data.)
Comments
Post a Comment