468,538 Members | 1,582 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,538 developers. It's quick & easy.

String.Format: What is "{0}"

I have the following:

String.Format("{0}", myNumber);

What is {0} called? The reason I ask is that I want to look up how present
myNumber as 2 digits in the string. For example, if myNumber is 3, the string
should be 03. If I just use something like {0:2}, I get a space preceeding
the 3.

Thanks,
Randy
Apr 25 '07 #1
2 4452
Search for "Standard Numeric Format Strings" and "Custom Numeric Format
String" in help.

Going from memory I believe what you want is {0:00} or {0:N02}. The
latter handles negative numbers and thousand separators, the former just
left-justifies with zeros.

--Bob

randy1200 wrote:
I have the following:

String.Format("{0}", myNumber);

What is {0} called? The reason I ask is that I want to look up how present
myNumber as 2 digits in the string. For example, if myNumber is 3, the string
should be 03. If I just use something like {0:2}, I get a space preceeding
the 3.

Thanks,
Randy
Apr 26 '07 #2
HI,
Have a look at
http://msdn2.microsoft.com/en-us/library/fht0f5be.aspx
HTH,
James
On 26 Apr, 00:22, randy1200 <randy1...@discussions.microsoft.com>
wrote:
I have the following:

String.Format("{0}", myNumber);

What is {0} called? The reason I ask is that I want to look up how present
myNumber as 2 digits in the string. For example, if myNumber is 3, the string
should be 03. If I just use something like {0:2}, I get a space preceeding
the 3.

Thanks,
Randy

Apr 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by phmyhn | last post: by
2 posts views Thread by Joebloggs | last post: by
6 posts views Thread by =?Utf-8?B?SmVmZg==?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.