首页 > 代码库 > C#格式化数字

C#格式化数字

        var t1 = Profiler.GetMonoHeapSize()/div;
        var t2 = Profiler.GetMonoUsedSize() / div;
        var t3 = Profiler.GetTotalAllocatedMemory() / div;
        var t4 = Profiler.GetTempAllocatorSize() / div;
        var t5 = Profiler.GetTotalReservedMemory() / div;
        var t6 = Profiler.GetTotalUnusedReservedMemory() / div;
        var t7 = Profiler.usedHeapSize / div;
        var t8 = Profiler.enabled;
//         var str = string.Format("f", 120.3457f);
//         var str1 = string.Format("g", 120.3457f);
//         var str2 = string.Format("{0:f}", 120.3457f);
//         var str3 = string.Format("{0:0.000}", 120.3457f);
//         var str4 = string.Format("{0:0000}", 120.3457f);
//         var str5 = string.Format("{0:0000}", 120);
        //var str7 = string.Format("{0:d4}", 120);

        text.text = "程序内存:" + t7.ToString("f") + ", monoHeap:" +t1.ToString("f") + ",monoUsed:" + t2.ToString("f")+ ",all:" + t3.ToString("g");

 

C#格式化数字