只是,

class Program
{
    static void Main( string [ ] args )
    {
        int i = 010;

        Console.WriteLine( i );

        Console.ReadKey( );
    }
}


输出:


  10


如何停止修剪前导零?
小数具有相同的输出,字符串也不是最佳解决方案。

最佳答案

您需要将其存储在字符串中。然后,您可以在需要计算时将其转换回整数,然后在使用所需格式完成后将其转换回字符串。

关于c# - 整数修剪从零开始,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13616591/

10-13 04:31