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
 
Back
Top