gpt4 book ai didi

c# - 如何从 stringformat 显示 99.99 中的 100

转载 作者:行者123 更新时间:2023-12-02 18:29:07 24 4
gpt4 key购买 nike

我想使用字符串格式将其四舍五入到 100,而不是 math.round,因为在代码中我无法使用 math.round。

最佳答案

如果像这样将精度设置为一位数,则该数字将向上舍入为 100.0。您可以使用字符串插值,而不必像这样指定 String.Format:

Console.WriteLine($"{99.99:0.0}");

关于c# - 如何从 stringformat 显示 99.99 中的 100,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69683018/

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