String.Format: What is "{0}"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top