c# double to 1 decimal place code example
Example 1: c# double value with 2 decimal places
inputValue = Math.Round(inputValue, 2);
Example 2: format double to 2 decimal places in c#
priceLbl.Text = price.ToString("0.##");
Example 3: C# .net core convert to int round up
// Use Math.Ceiling to round up
Math.Ceiling(0.5); // 1
// Use Math.Round to just round
Math.Round(0.5, MidpointRounding.AwayFromZero); // 1
// And Math.Floor to round down
Math.Floor(0.5); // 0