GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
Tue, 2009-03-03 11:32 — Chris Charabaruk
using System;
namespace TestApp
{
public static class ExtensionMethods
{
public static int RoundOff (this int i)
{
return ((int)Math.Round(i / 10.0)) * 10;
}
}
public class TestApp
{
public static void Main()
{
int roundedNumber = 236.RoundOff(); // returns 240
int roundedNumber2 = 11.RoundOff(); // returns 10
Console.WriteLine(roundedNumber);
Console.WriteLine(roundedNumber2);
}
}
}
A C# extension method which takes an integer and rounds it to the nearest multiple of 10. Written in response to this question on Stack Overflow.