asp.net remove leading zeros from user input

I have a job number text box that requires three numerics (999).  In the code behind I want to store a string value of the number with no leading zeros.  IE, job '009' should store '9'.  job '099' should store '99', etc...

Does .net have a function for that?
JT_SIROAsked:
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.

Scott CraigWebmasterCommented:
You should be able to use TrimStart:

string a = "000012340";
string b = a.TrimStart('0');

Open in new window

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
Navneet.Net Full Stack DeveloperCommented:
Hi!

Convert.ToInt32("009");

Thanks!
0
käµfm³d 👽Commented:
Or you might prefer to validate that you have a number also:

int x;

if (int.TryParse(textBox1.Text, out x))
{
    // text is a valid number
    string y = x.ToString();
}

Open in new window

0
JT_SIROAuthor Commented:
oooh, TrimStart!  I didn't know about that.  I wouldn't have had to written this:

public string trimZeros(string s)    
    {
        int len;
        len = s.Length;

        s = s.Trim();

        if (s.Substring(0, 1) == "0")
        {
            s = s.Substring(1, len - 1);
            if (s.Substring(0, 1) == "0")
            {
                s = s.Substring(1, 1);
            }
        }

        return s;
    }
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.