C# round to integer code example
Example 1: c# round number
double number = 1.5362
int rounded = Math.Round(number)
double rounded_2 = Math.Round(number, 2)
Example 2: 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);