Solved

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

Posted on 2006-06-30
2
223 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 500 total points
ID: 17016864
How about:

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

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IO.FileSystemWatcher dies when used in Powershell 1 45
Runtime Exceptions when trying to submit data 28 37
System.Speech 2 16
Windows Media Player 2 16
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

17 Experts available now in Live!

Get 1:1 Help Now