C#的out关键词,即是方法内赋值。

返回处理后的结果。打个比喻,有一个宽度的需要按比例缩放。标准宽度为88,如宽度大于这个标准宽度的话,按照0.8进行缩放。如果小于标准宽度,输出的结果没变化。

此时,你可以写一个方法:

C# out关键词应用

 public static void ReSizeWidth(double originalWidth, double rate, int standardLength, out double resizeWidth)
        {
            resizeWidth = originalWidth;

            if (originalWidth > standardLength)
            {
                resizeWidth = originalWidth * rate;
            }
        }
Source Code

相关文章:

  • 2021-08-21
  • 2021-09-18
  • 2021-12-24
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2021-07-11
  • 2021-08-19
  • 2022-12-23
  • 2021-11-10
相关资源
相似解决方案