Pet*_*kem 2 c# string.format zero
在我的应用程序中,有可能使用该string.Format()函数格式化字符串.我希望在结果为零时添加返回空白的可能性.
据我所知,可以使用代码执行此操作:0.toString("0;; ");,但正如我已经提到的,我需要使用该string.Format()函数(因为它必须能够使用例如{0:P}百分比的格式.
有谁知道如何使用该string.Format()函数消隐零值?
谢谢你,彼得
小智 8
我的回答有点晚,但你可能想尝试以下方法:
{0:#.##%;-#.##%;''}
Run Code Online (Sandbox Code Playgroud)