简体   繁体   中英

How to remove zero in a string

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM