Guilherme Cardoso Guilherme Cardoso - 1 year ago 80
C# Question

C# - Round numbers to 0 decimals

I need to round numbers to 0 decimals (for a pagging system).

I've already tried something like this:

Math.Round(double1, 0, MidpointRounding.AwayFromZero);

If the double1 be 7,2 or 7,6 i need it to round for 8 but i'm not getting that.

Can someone help me, please?


Answer Source

Use Math.Ceiling to always round up to the next integer:

double roundUp = Math.Ceiling(double1); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download