Format a string to a currency with negative currency like $(10.00)
.net, c#, currency-formatting, string-formatting
Solution
itemPrice.ToString(@"$#,##0.00;$\(#,##0.00\)");
Should work. I just tested it on PowerShell:
PS C:\Users\Jcl> $teststring = "{0:$#,##0.00;$\(#,##0.00\)}"
PS C:\Users\Jcl> $teststring -f 2
$2,00
PS C:\Users\Jcl> $teststring -f -2
$(2,00)
Is that what you want?
Problem
I need to format a negative currency as follow: `$(10.00)` I tried to use `string.Format("{0:C}", itemprice)` but that gives me this result `($10.00)` (the $ inside the parenthesis i also tried ``` string fmt = "##;(##)"; itemprice.ToString(fmt); ``` but it gives me the same as before `($10.00)` Any idea on how to get a result like this: `$(10.00)`.