So I have kinda helper with this code which I use everywhere in system where I need to round a double:
public static double Round(double source)
{
return Math.Round(source, Program.AppSettings.DigitAfterComma);
}
The idea is to round any input double to double with some character after comma which is read from file. I use it in my services with calculations and in my ViewModels and .cshtml for results render.
The problem is that dealing with calculations is OK, but when I need to render doubles like 15.0% I get only 15% as output. It will be hard to write 2 methods for renderer and for calculations because this method has a numerous references all over the system.
Is there any way to get xx.0 everytime I call the method without formatting it to string because I need double type output for calculations?