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.
Who is Participating?
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');
Ronak PatelCommented:
Hi axnst2,

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

Hope this helps.

axnst2Author Commented:
Thank you.  I was interperting the total width as the number needed to make it the final length.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.