简体   繁体   English

如何删除字符串中的零

[英]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嗨,我正在从应用程序中处理 c# windows,我需要在字符串上删除零,但如果下一个字符不为零,它将停止删除

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:使用接受charTrimStart()重载来删除:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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