Geekus Con Livus

Malcolm Anderson's home for Geeks With Lives
posts - 63, comments - 51, trackbacks - 23

My Links

News

Archives

Post Categories

Was it that hard to document?

All I wanted was to take a numeric string, and increment it.  The string happened to be 2 digits long.

All I wanted to do was something along the lines of var.ToString().PadLeft(2).

So off to google I went, and I finally found my answer, but not in any MSDN documentation.  The MSDN docs refer to format strings as if I use them EVERY single day.  I don't.  I deal with them about once every 3 months, (but this time ... I'm writing it down)

 

I eventually found this method

stringVar = intVar.ToString().PadLeft( 2, '0' );

Anyway, I finally found this on SteveX's blog which is what I wanted in the first place.

stringVar = intVar.ToString("00");

 

Yes, I'm hard coding it to two digits, I know, “bad programmer“.  I can hack it to length later, I just didn't want to have to write “leading zero code.

Print | posted on Tuesday, July 05, 2005 5:02 PM | Filed Under [ Stupid Code Tricks ]

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: