============================decimal保留小数位后两位,使用四舍五入。=================
decimal price = 12.128123M;
price = decimal.Parse(string.Format("{0:F2}", price));
Console.WriteLine(price);
Console.ReadKey();
============================利用时间差计算部分时间=================
TimeSpan sp = new TimeSpan(0, 65, 0);
Console.WriteLine(String.Format("{0}天{1}时{2}分", sp.Days, sp.Hours, sp.Minutes));
Console.ReadKey();
本文介绍如何在C#中使用decimal类型保留小数点后两位并进行四舍五入的操作,同时展示了如何利用TimeSpan来计算特定的时间差。
7738

被折叠的 条评论
为什么被折叠?



