C# Pad string with trailing zeros

I have a customer number that is a string that varies in length.  It can vary any where from 7 digits to 12 digits.  When I am processing the data, I need the final string length to be 12 digits.  I have tried (in c#) using string.PadRight(int, '0') and this does not work.  All my searching online has indicated that this is the solution.  Here is the sinipet of code that is failing.  

int padCount = (12-invoiceFromDB.ArCustomerId.Length);
arCustomerId = invoiceFromDB.ArCustomerId.PadRight(padCount, '0');

So if I have a customer number of 123456, when the above code is executed, I end up with a customer number of 123456 instead of 123456000000.
axnst2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
When you pad, you do not specify the number of character to add. You simply states the final number of characters that you want, and the method handles the count:

 invoiceFromDB.ArCustomerId.PadRight(12, '0');
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ronak PatelCommented:
Hi axnst2,

Please refer this msdn article: String.PadRight Method for more information.


Hope this helps.

Regards,
Ronak
0
axnst2Author Commented:
Thank you.  I was interperting the total width as the number needed to make it the final length.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.