Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

500pts: Using String.Format to format a string ??

Posted on 2006-06-30
2
Medium Priority
?
235 Views
Last Modified: 2010-04-16
Hi there,

Can anyone help?

I have a string but it contains numbers i.e. 3000000

I would like to format it to 3,000,000 but remembering it isn't a integer ... it is already a string,

I did try this, Console.WriteLine(String.Format("{0:n}",row["NUM"].ToString()));

But it still returns 3000000

Should i convert it to an integer first or something? can it not work on strings????

Thanks in advance

Ian
0
Comment
Question by:ianinspain
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 17016864
How about:

   Console.WriteLine("{0:#,###,###}", Int32.Parse(val));
0
 

Author Comment

by:ianinspain
ID: 17017082
cool! thanks...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview
Suggested Courses

885 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