Eliminate Leading Zeros

  • Thread starter Thread starter Beebs
  • Start date Start date
B

Beebs

If I have the following string "00038975" how can I iterate through
the characters and return all but the leading zeros? I need "38975"
to be returned from the original string.

Thanks
 
Beebs said:
If I have the following string "00038975" how can I iterate through
the characters and return all but the leading zeros? I need "38975"
to be returned from the original string.

Thanks


while (theString.StartsWith("0"))
theString = theString.SubString(1);
 
This is the best one. The right one would be to use Regular Expressions <g>
 
The fastest one is using directly the Chars property. <famous last words>

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top