Solved

Display a number with both comma seperators and NO decimal places?

Posted on 2006-06-14
2
322 Views
Last Modified: 2010-04-16
C# application.

Hi,

I've a double such as '34567', and I need to display this as label text as '34,567'.  Note that I do not want to display any decimal places.

I have managed to get the comma delimiters inserted by using:

NumberFormatInfo nfi = new CultureInfo( "en-US", true ).NumberFormat;
double GIA = 34567;
Label10.Text = GIA.ToString("N", nfi);

result = 34,567.00 <--NOTE that the result includes decimal places!

So the question once more is, how can I get both the comma delimiters AND no decimal places?

Thanks for your help.
0
Comment
Question by:NAORC
[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
2 Comments
 
LVL 10

Accepted Solution

by:
SystemExpert earned 500 total points
ID: 16901091
Hi,

Label10.Text = GIA.ToString("0,00");

Thanks
0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16901216
Hi,
The exact code with globalization is

double GIA = 34567;
NumberFormatInfo nfi = new CultureInfo( "en-US", true ).NumberFormat;
Response.Write(GIA.ToString("0,00", nfi));

Regards
Pradeep
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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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