float num = 3.5678f;
float roundedNum = (float)Math.Round(num, 2); // 3.57
float num = 3.5678f;
float roundedNum = float.Parse(num.ToString("0.00")); // 3.57
public static float Round(float num, int decimals)
{
float factor = (float)Math.Pow(10, decimals);
return (float)Math.Round(num * factor) / factor;
}
float num = 3.5678f;
float roundedNum = Round(num, 2); // 3.57