formatnumber

1799,
How can I show this number as 1.799

In classic asp i just write formatnumber()

How in c# ?
Jesper ChristensenProgrammerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
w00teConnect With a Mentor Commented:
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
 
rockiroadsCommented:
have u tried tostring("N3") on your variable? you may need to divide by 1000
0
 
rockiroadsCommented:
or is this supposed to be the 1000th character?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
DhaestCommented:
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
 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
0
 
Jesper ChristensenProgrammerAuthor Commented:
Thanks for the answers. I will try if it works and get back to you
0
 
Jesper ChristensenProgrammerAuthor Commented:
This is correct syntax:
{0:0,00}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.