How to remove zero in a string

Viewed 116

Hi i'm working on c# windows from application and i'm required to remove zero on a string but if the next char is not zero it will stop removing

sample data

040079       ->40079
003144       ->3144
440079       ->440079

How can I achieve this hope someone help me out

1 Answers

Use the TrimStart() overload that accepts a char to remove:

"040079".TrimStart('0') //"40079"
"003144".TrimStart('0') //"3144"
"440079".TrimStart('0') //"440079"
Related