C# - (int)Math.Round((double)(3514 + 3515)/2) =3514?
问题 Helo everyone. int[] ai1=new int[2] { 3514,3515 }; void average1() { List<int> aveList = new List<int> { ai1[0],ai1[1]}; double AveragLI = aveList.Average(); int AverLI = (int)Math.Round((double)AveragLI); label1.Text = AverLI.ToString(); } Returns 3514; should not be 3515? 回答1: Math.Round is the culprit int AverLI = (int)Math.Round((double)AveragLI); Its what we call Banker's Rounding or even rounding. Info on Math.Round says The integer nearest a. If the fractional component of a is halfway