gpt4 book ai didi

c# - 如何重新格式化字符串以排除前导零?

转载 作者:太空狗 更新时间:2023-10-29 19:48:43 26 4
gpt4 key购买 nike

我有这样的字符串:

var abc = "002";
var def = "023";

如何轻松更改字符串以删除前导零?

最佳答案

看看TrimStart :

numberString = numberString.TrimStart('0');

来自 MSDN:

The TrimStart method removes from the current string all leading characters that are in the trimChars parameter. The trim operation stops when a character that is not in trimChars is encountered.

关于c# - 如何重新格式化字符串以排除前导零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6929542/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com