how to fix the error on the Round, what should i change the line to?

public void ChangeTexts(long length, int position, int percent, double speed)
        {
            Label3.Text = "File Size: " + Math.Round((length / 1024), 2) + " KB";

Severity Code Description Project File Line Suppression State Error CS0121 The call is ambiguous between the following methods or properties: 'Math.Round(double, int)' and 'Math.Round(decimal, int)'

Jon Skeet
people
quotationmark

You're currently dividing by 1024 in integer arithmetic and then rounding the result. In other words, you're rounding something that's already an integer - not really useful.

The simplest fix is to divide by 1024.0 instead, to make it happen in double arithmetic:

Label3.Text = "File Size: " + Math.Round((length / 1024.0), 2) + " KB";

Or better, just do it within the formatting itself:

Label3.Text = $"File Size: {length / 1024.0:0.00}KB";

people

See more on this question at Stackoverflow