PC Review


Reply
Thread Tools Rate Thread

convert int to numeric (formatted) string

 
 
raulavi
Guest
Posts: n/a
 
      10th Mar 2008

vs2005 c#

hi:
need to convert a simple int to a format nnnn. if I have int 1 I want the
result to be padded with 0s as 0001 on a string

I have int 1 and I want "0001"

any help. Thanks

so far these dont work
field.ToString("nnnn") or field.ToString("####")
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      10th Mar 2008
raulavi <(E-Mail Removed)> wrote:
> hi:
> need to convert a simple int to a format nnnn. if I have int 1 I want the
> result to be padded with 0s as 0001 on a string
>
> I have int 1 and I want "0001"
>
> any help. Thanks
>
> so far these dont work
> field.ToString("nnnn") or field.ToString("####")


"0000" works fine.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
 
Reply With Quote
 
raulavi
Guest
Posts: n/a
 
      11th Mar 2008
Thanks this works.

"Jon Skeet [C# MVP]" wrote:

> raulavi <(E-Mail Removed)> wrote:
> > hi:
> > need to convert a simple int to a format nnnn. if I have int 1 I want the
> > result to be padded with 0s as 0001 on a string
> >
> > I have int 1 and I want "0001"
> >
> > any help. Thanks
> >
> > so far these dont work
> > field.ToString("nnnn") or field.ToString("####")

>
> "0000" works fine.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
> World class .NET training in the UK: http://iterativetraining.co.uk
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert string value to numeric value alhotch Microsoft Access Queries 3 26th May 2010 01:47 PM
Convert Formatted Double Into String Derek Hart Microsoft Dot NET 2 7th Jul 2008 07:18 PM
Convert Formatted Double Into String Derek Hart Microsoft VB .NET 2 7th Jul 2008 07:18 PM
Convert formatted string to string? rockdale Microsoft ASP .NET 3 12th Apr 2006 04:01 PM
Anyone have a regex expression to create a numeric-only string from a formatted string? Ray Stevens Microsoft C# .NET 2 16th Mar 2005 07:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:44 PM.