Skip to content

Instantly share code, notes, and snippets.

@zyowo
Created July 22, 2020 08:11
Show Gist options
  • Save zyowo/4cf443feef52ffd67520a9a48460eaf7 to your computer and use it in GitHub Desktop.
Save zyowo/4cf443feef52ffd67520a9a48460eaf7 to your computer and use it in GitHub Desktop.
Gist 就是分享代码段的地方?
/// <summary>
/// [范围限定] 将数字限定在 最小 ~ 最大之间
/// </summary>
/// <param name="value">限定数字</param>
/// <param name="min">最小值</param>
/// <param name="max">最大值</param>
/// <returns>限定后结果</returns>
public static int Clamp(int value, int min, int max)
{
if (max < min) return value;
if (value < min) value = min;
if (value > max) value = max;
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment