c# round numbers code example
Example 1: c# round number down
double number = 1.5362
int floored = Math.Floor(number)
Example 2: C# .net core convert to int round up
Math.Ceiling(0.5);
Math.Round(0.5, MidpointRounding.AwayFromZero);
Math.Floor(0.5);
Example 3: round to the nearest whole number c#
var roundedA = Math.Round(1.1, 0);
var roundedB = Math.Round(1.5, 0, MidpointRounding.AwayFromZero);
var roundedC = Math.Round(1.9, 0);
var roundedD = Math.Round(2.5, 0);
var roundedE = Math.Round(2.5, 0, MidpointRounding.AwayFromZero);
var roundedF = Math.Round(3.49, 0, MidpointRounding.AwayFromZero);