Solved

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

Posted on 2006-06-30
2
225 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
MediaHelp 4 26
FTP file download using c# 3 25
Can I command line build a C# application? 6 40
Please explain purpose of GZIP 4 37
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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.

828 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