Solved

formatnumber

Posted on 2010-09-02
7
591 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 33586972
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
ID: 33586974
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
ID: 33587002
or is this supposed to be the 1000th character?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:Dhaest
ID: 33587086
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
ID: 33587120
0
 

Author Comment

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

Author Closing Comment

by:bongii
ID: 33594728
This is correct syntax:
{0:0,00}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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