Add Zeroes to a string

Posted on 2007-07-23
Medium Priority
Last Modified: 2010-04-16

How do i check if a string has less than 8 characters in C# and if it has, fill it to 8 characters with zeroes



input: 99
output: 00000099

Question by:jedistar
LVL 10

Assisted Solution

SystemExpert earned 400 total points
ID: 19546316
int large = 99;
label1.Text =(large.ToString("00000000")); //output: 00000099

Accepted Solution

icr earned 600 total points
ID: 19546416
string numberString = "99";
numberString = numberString.PadLeft(8, '0');

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question