IUAATech
asked on
prepend a string to an exisiting string
I am looking to prepend 10-x #s of 0's to a string if its lenth is less than 10 and has a length x.
so if I have 12345 I want to end up with 0000012345.
What a short and sweet way of doing this? :)
Thanks.
so if I have 12345 I want to end up with 0000012345.
What a short and sweet way of doing this? :)
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if your 12345 is an integer then you don't have to Convert.ToInt32(a) in the format, but if it's a string then you will, or else the leading 0's will not come through
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PadLeft is actually the way to go on this... duh! Why didn't I think of that?
ASKER
thanks guys.