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

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -