Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

809 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