471,356 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,356 software developers and data experts.

formatting strings with leading characters

How can I add characters to an incomplete string. I want it:
Ex:
"12" to "0012"

That's exactly what I need, I prefer using string. If there's no way, I'd
like to know how make an integer to change like the above example.
Jul 21 '05 #1
2 1073
str="00" & 12 in vb.net
str="00" + 12 in C#

Try it

Tony

"Leomach" <Le*****@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
How can I add characters to an incomplete string. I want it:
Ex:
"12" to "0012"

That's exactly what I need, I prefer using string. If there's no way, I'd
like to know how make an integer to change like the above example.

Jul 21 '05 #2
Using integers:

int i = 12;
Console.WriteLine(i.ToString("0000"));

HTH, Jakob.

"Leomach" wrote:
How can I add characters to an incomplete string. I want it:
Ex:
"12" to "0012"

That's exactly what I need, I prefer using string. If there's no way, I'd
like to know how make an integer to change like the above example.

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Ravi | last post: by
2 posts views Thread by Stian | last post: by
26 posts views Thread by Nige | last post: by
2 posts views Thread by Ingo Nolden | last post: by
4 posts views Thread by Robert Manookian | last post: by
4 posts views Thread by | last post: by
11 posts views Thread by Dustan | last post: by
5 posts views Thread by Berryl Hesh | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.