舍入到最接近的五C# [英] Round to nearest five C#

查看:99
本文介绍了舍入到最接近的五C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#,我需要圆一个双到最近五。我不能找到一种方法与Math.Round功能来做到这一点。我怎样才能做到这一点。

I'm using C# and I need to round a double to nearest five. I can't find a way to do it with the Math.Round function. How can I do this?

我要什么?

70 = 70
73.5 = 75
72 = 70
75.9 = 75
69 = 70

等..

有一个简单的方法来做到这一点?

Is there an easy way to do this?

推荐答案

尝试:

Math.Round(value / 5.0) * 5;

这篇关于舍入到最接近的五C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆