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 3619976
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:56:47+00:00 2026-05-18T22:56:47+00:00

I am using next code to format double value: String.Format(${0:0,0.#},…); It working great, but

  • 0

I am using next code to format double value:

String.Format("${0:0,0.#}",...);

It working great, but when numbers are less than 10, I got problem. Numbers are displayed as $03, $06 for example.

Please advise me correct string to have a double number in next format ddd,ddd,ddd,ddd.dd

  • 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-05-18T22:56:48+00:00Added an answer on May 18, 2026 at 10:56 pm

    Try this instead:

    string result = string.Format("${0:#,##0.00}", d);
    

    If your double represents a currency you should use:

    string result = string.Format(CultureInfo.GetCultureInfo("en-US"), "{0:c}", d);
    

    Note that if you omit the CultureInfo.InvariantCulture it could display using something other than $ on some computers. For example on my computer string.Format("{0:c}", d) gives 2,00 kr which might not be what you wanted.

    In your example you don’t actually need to use string.Format at all. You could use this instead:

    string s = d.ToString("c", CultureInfo.GetCultureInfo("en-US"));
    

    As well as being clearer and more concise, it also has the advantage of avoiding boxing. Of course if your format string is more complex than in your example then it would make sense to use string.Format.

    And as a final remark I’d recommend against using doubles to store currency. A decimal type is probably more appropriate.

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

Sidebar

Related Questions

For Each line As String In System.IO.File.ReadAllLines(file.txt) 'Do Something' Next and Using f As
We're considering writing the next version of out project in using .Net 3, but
I am creating a Word format .doc using the following code, then cfheader and
I'm not primarily an html programmer, but I'm using HTML to format the display
I am using the next class (simplified for the sake of understandability) to download
My next project is going to be using Windows Communication Foundation to host Managed
Using jQuery, what's the best way to find the next form element on the
My team is considering building our next web app using the ASP.NET MVC framework.
I am currently studying and my next subject is 'Programming Using Alice'. Has anyone
I am using jQuery. I call a JavaScript function with next html: <li><span><a href=javascript:uncheckEl('tagVO-$id')>$tagname</a></span></li>

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.