String format for currency(negative value formatted with braces)

When we convert like String.Format("{0:C}", 126.45) it returns $126.45

but if we convert like String.Format("{0:C}", -126.45) it returns ($126.45)

Why negative conversion return braces? What to do if we don't want this braces?

Why don't you try something like:

String.Format("{0:$#,##0.00}", -126.45)

According to the documentation here a format of "{0:C1}" or "{0:C2}" should work, but for some strange reason it is not..

Another approach could be setting the CultureInfo:

CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.NumberFormat.CurrencyNegativePattern = 1;
string s = string.Format(culture, "{0:c}", -126.45);

Reference here

String format for currency(negative value formatted with braces), Why don't you try something like: String.Format("{0:$#,##0.00}", -126.45). According to the documentation here a format of "{0:C1}" or "{0:C2}" should work, but� Does anybody know how can I format negative currency and show it between parenthesis? System.String.Format("{0:c2}", -12345) --> -$12,345.00. System.String.Format("{0:c}", -12345) --> -$12,345.00. Both above method show same result, but I want to show the number (12, 345) Thank you in advance for your time. Alex

Swift 5 Here is best solution if you get after formate this kind of value (-300)

extension Double {
static let twoFractionDigits: NumberFormatter = {
    let formatter = NumberFormatter()
    formatter.numberStyle = .decimal
    formatter.minimumFractionDigits = 2
    formatter.maximumFractionDigits = 2
    formatter.currencySymbol = "$"
    formatter.currencyCode = "USD"
    formatter.numberStyle = .currency
    formatter.usesGroupingSeparator = true

    return formatter
var formatted: String {
    return Double.twoFractionDigits.string(for: self) ?? ""


How to Format Negative Values with Brackets in SQL Server (T-SQL , Here's a quick way to add brackets around negative numbers in SQL When calling this function, you pass the value to be formatted, and a format string that numeric format specifier, that formats the number as a currency. The "C" (or currency) format specifier is used to convert a number to a string representing a currency amount. Let us see an example. double value = 139.87; Now to display the above number until three decimal places, use (“C3”) currency format specifier. value.ToString("C3", CultureInfo.CurrentCulture) Let us see another example. Example. Live Demo

In the en-US locale, parentheses are used to denote negative values. Visually scanning a long column of numbers, many people find it easier to see the negatives. Often it's the negative values that are of most concern (oops! my checking account balance is overdrawn).

To get different formatting behavior, you can change your locale, or you can change your format specifier to something like F.

String.Format(“{0:C2}”, -1234) (Currency format) treats negative , String.Format(“{0:C2}”, -1234) (Currency format) treats negative numbers as Am I right in saying it's putting it in brackets, i.e. it's formatting it as ($1,234.00) ? For example, the format £##*~.00 displays a currency amount as £45~~~~~.15. The number of tilde characters (~) displayed in the field depends on the number of blank spaces in the table field. % Used as the last character in a format string. Multiplies the value by 100 and displays the result with a trailing percent sign. E+, E-–or– e+, e-

It does parentheses, because that's the standard on whatever CultureInfo you are using.

Never done it myself but the make up of the format is controlled by the current NumberFormatInfo instance.

If you figure it out, answer your own question, and I'll plus you

Formatting a Negative Number with Parentheses in Microsoft Excel, To apply the custom formatting in cell follow below steps:- Method 1: We have some negative numbers in column B. To Format the Negative Numbers in Red Color with brackets: Enter '0' in the Decimal placesbox to avoid decimals. Click on� Required. One or more values that should be formatted and inserted in the string. The values can be A number specifying the position of the element you want to remove. The values are either a list of values separated by commas, a key=value list, or a combination of both. The values can be of any data type.

Formatting a Negative Number Output with Parentheses in Java, A negative number output can be shown using the Formatter object −Formatter f = new Formatting a Negative Number Output with Parentheses in Java Formatter; public class Demo { public static void main(String args[])� When we would like to get something like {name} as an output , it needs 3 curly braces as string.Format("{{{0}}}",name) – Davut Gürbüz Aug 28 '14 at 8:48 6 @JacekGorgoń Any page is more readable than MSDN – amrswalha Oct 19 '15 at 12:54

SteveX Compiled � String Formatting in C#, The group separator is especially useful for formatting currency values which require that negative values be enclosed in parentheses. This currency formatting� Format strings contain “replacement fields” surrounded by curly braces {}. Anything that is not contained in braces is considered literal text, which is copied unchanged to the output. If you need to include a brace character in the literal text, it can be escaped by doubling: { { and }}.

Format numeric strings, A numeric-formatting mask specifies a format to apply to some numeric value. of accounting parentheses that replace a minus sign for a negative number. not set this environment variable, the numeric-formatting functions use the currency� For example, if you have an integer value of 100 that you want to represent to the user as a currency value, you could easily use the ToString method and the currency-format string ("C") to produce a string of "$100.00".