In a programme:
Decimal a = 7m; Console.WriteLine("{0:C}", a); Conclusion: 7.00?
Without a currency sign and with a question mark at the end. What need to do?
In a programme:
Decimal a = 7m; Console.WriteLine("{0:C}", a); Conclusion: 7.00?
Without a currency sign and with a question mark at the end. What need to do?
First, in the error code, it will be correct to do the output like this:
Console.WriteLine("{0:C}", a); Not there were braces.
And secondly, for the rest - everything is true, it should be so. Namely: you specify a variable of the monetary type decimal a = 7m , which should be displayed with a currency sign. What kind of currency sign will be used - is taken from the regional settings of the system. In the case of the Russian regional settings, this will be the ruble, and the currency sign, which should be issued - $.
But you have here output to the console, which, in turn, uses to display the font, which does not have this character, and therefore displays a question mark instead.
UPD: Under Win 7, the following code displays everything correctly:
decimal a = 7m; var s = string.Format("{0:C}", a); MessageBox.Show(s); Source: https://ru.stackoverflow.com/questions/583088/
All Articles