/// <summary>字节单位换算</summary>
public static string ByteConversion(double length)
{
string temp;
if (length < 1024)
{
temp = Math.Round(length, 0) + "B";
}
else if (length < 1024 * 1024)
{
temp = Math.Round(length / (1024), 0) + "KB";
}
else if (length < 1024 * 1024 * 1024)
{
temp = Math.Round(length / (1024 * 1024), 2) + "MB";
}
else
{
temp = Math.Round(length / (1024 * 1024 * 1024), 2) + "GB";
}
return temp;
}
字节单位换算
原创
©著作权归作者所有:来自51CTO博客作者DaLiangChen的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:将时间戳转换为时间
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
CSS 的值与单位——WEB开发系列21
在 CSS 中,每个属性都可以接受一个或多个值。CSS 提供了多种值和单位,以便我们能够精确地控制页面的布局和样式。
css html web 前端 css3