Solved

formatnumber

Posted on 2010-09-02
7
580 Views
Last Modified: 2013-12-17
1799,
How can I show this number as 1.799

In classic asp i just write formatnumber()

How in c# ?
0
Comment
Question by:bongii
7 Comments
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
have u tried tostring("N3") on your variable? you may need to divide by 1000
0
 
LVL 12

Accepted Solution

by:
w00te earned 500 total points
Comment Utility
http://www.csharp-examples.net/string-format-double/
Examples of every type of formatting.  do {0:0.000} for yours.
// just two decimal places
String.Format("{0:0.00}", 123.4567);      // "123.46"
String.Format("{0:0.00}", 123.4);         // "123.40"
String.Format("{0:0.00}", 123.0);         // "123.00"
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
or is this supposed to be the 1000th character?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 53

Expert Comment

by:Dhaest
Comment Utility
http://msdn.microsoft.com/en-us/library/0c899ak8(v=VS.100).aspx
double value;



value = 123;

Console.WriteLine(value.ToString("00000"));

// Displays 00123



value = 1.2;

Console.WriteLine(value.ToString("0.00", CultureInfo.InvariantCulture));

// Displays 1.20

Console.WriteLine(value.ToString("00.00", CultureInfo.InvariantCulture));

// Displays 01.20

Console.WriteLine(value.ToString("00.00", 

                  CultureInfo.CreateSpecificCulture("da-DK")));

// Displays 01,20



value = .56;

Console.WriteLine(value.ToString("0.0", CultureInfo.InvariantCulture));

// Displays 0.6



value = 1234567890;

Console.WriteLine(value.ToString("#,#", CultureInfo.InvariantCulture));	

// Displays 1,234,567,890      

Console.WriteLine(value.ToString("#,#", 

                  CultureInfo.CreateSpecificCulture("el-GR")));	

// Displays 1.234.567.890      

Open in new window

0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
Comment Utility
0
 

Author Comment

by:bongii
Comment Utility
Thanks for the answers. I will try if it works and get back to you
0
 

Author Closing Comment

by:bongii
Comment Utility
This is correct syntax:
{0:0,00}
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now