given value = 2 or 4.00
the below statement outputs
value = Convert.ToDecimal(value).ToString("C2");
value = $2.00, or $4.00
if I have value = 1000 then output will be $1,000.00 but I require $1000.00.
I don’t prefer string concatenation of “$” and value.
As noted by @James below, this hard-codes the currency into the format. Using the format
C2will use the system currency format. This can be changed for the system (e.g. in Windows 7 – Start – Control Panel – Change Display Language – Additional Settings – Currency – Digit grouping) and will allow theC2format to display the currency value without the comma when running on that particular system.EDIT
All credit to @James for using the current culture. My only modification to his answer would be to clone the current
NumberFormatso as to get all the properties of the current culture number format before removing theCurrencyGroupSeparator.