Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7737445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:59:57+00:00 2026-06-01T07:59:57+00:00

I am trying to do something very similar to this c# docs example :

  • 0

I am trying to do something very similar to this c# docs example:

int value = 123;
Console.WriteLine(value.ToString(@"\#\#\# ##0 dollars and \0\0 cents \#\#\#"));
// Displays ### 123 dollars and 00 cents ###

Except I want it to actually work with decimals:

double value = 123.095;
Console.WriteLine(value.ToString(@"\#\#\# ##0 dollars and 0000 \#\#\#"));
// Should display ### 123 dollars and 0950 ###, but it doesn't (of course)

Tried:

Console.WriteLine(value.ToString(@"\#\#\# ##0. dollars and 0000 cents \#\#\#"));

But prints the decimal separator (of course), which I don’t want.
I know I could do something like this:

String.Format("{0:##0} {1:0000}", 123, 123);

But would very much like to avoid unless there is no other way

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:59:58+00:00Added an answer on June 1, 2026 at 7:59 am

    You can define your own special currency format, but… I’m not sure if I would do this. It kind of seems like an abuse of the NumberFormatInfo object:

    EDIT: changed datatype of value from decimal to double

    // works with either decimal or double
    double value = 123.095;
    
    var mySpecialCurrencyFormat = new System.Globalization.NumberFormatInfo();
    
    mySpecialCurrencyFormat.CurrencyPositivePattern = 3;
    mySpecialCurrencyFormat.CurrencyNegativePattern = 8;
    mySpecialCurrencyFormat.NegativeSign = "-";
    mySpecialCurrencyFormat.CurrencySymbol = "cents";
    mySpecialCurrencyFormat.CurrencyDecimalDigits = 4;
    mySpecialCurrencyFormat.CurrencyDecimalSeparator = " dollars and ";
    mySpecialCurrencyFormat.CurrencyGroupSeparator = ",";
    mySpecialCurrencyFormat.CurrencyGroupSizes = new[] { 3 };
    
    
    Console.WriteLine(value.ToString("C", mySpecialCurrencyFormat));
    

    Output is “123 dollars and 0950 cents”

    EDIT: it might make more sense to use CurrencyNegativePattern 15 instead of 8, so that negative values cause the entire string to be surrounded by parenthesis, which might be less confusing than just putting a negative sign in front of the dollars. For example, using CurrencyNegativePattern = 15 causes -123.095 to be output as “(123 dollars and 0950 cents)”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something very similar to this example: https://developers.google.com/maps/documentation/javascript/examples/directions-simple All I am trying to
I'm trying to write something very similar to an IM client (for learning purposes
I know very little about JavaScript but despite this I'm trying to cobble something
I'm trying program something very similar to iPhone's Clock application. In Clock.app, when you
I'm trying to do something very similar to what thomas.mery posted, but can't make
My question is very similar to this topic . I'm trying to use jquery,
I am trying something very simple, but for some reason it does not work.
I'm trying to get something very subtle to work, it looks pretty awful right
I'm trying to do something very simple, yet I can't seem to find the
I am trying to accomplish something very simple, and I'm hoping someone can point

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.